Custom applet must be added in budgie-panel in every login

Hi to all.
I have developed an applet in python for ubuntu budgie (nothing special, just a button which opens a menu with menuitems and submenu) and installed it in /usr/lib/budgie-desktop/plugins manually (copy+paste) . As for now I can add it to panel and run it without a problem.But after every login this applet don’t stay “pinned” and I have to add it again and again.This occurred suddenly after a normal shutdown.
Also the applets in right box panel after every login are messed up.I have to restart budgie panel ( nohup budgie-panel --replace&) to get them in the right place(I mean in place where they were in previous session).
About the applet doesn’t stay pinned matter any suggestion would be appreciated .Also for the second one.
Thanks in advance.

1 Like

Suggest reset your panel

nohup budgie-panel --reset --replace &

Sometimes things get out of step when applets are uninstalled before they are removed from the panel

I am afraid that resetting panel didn’t solve the problem. I have to add the applet again and restart panel to have applets in the right position.

Could we have a look at the applet? Without the applet, do applets keep their position(s)? In other words: are we looking at one issue causing the other or are there two separate issues?

So I’ve checked it and I see that the issue is one.Without applet added , other applets keep their positions.
Also the code is in python and is in below link:

Not at home atm, but your applet has a few issues. You run t1, t2 = get_active_window() in a time (logging in) when there will not be any active window yet. loading the applet will break and the whole panel-loading procedure will be corrupted.

Another thing is that you use: subprocess.Popen(["./"]). I assume you are pointing to the applet’s own dir, but an applet is an add-on functionality, not a standalone executable. You need to use: os.path.dirname(os.path.abspath(__file__)) to get the applet’s directory. I’d also strongly suggest not to use global, especially not in an applet.

I’d suggest restructuring your applet a bit. Keep in mind the panel is as stable as its most unstable applet, and catches a cold easily. I am sure if you change a few things, the panel will be ok, also after a restart.

Thanks for the suggestions.
About t1, t2 = get_active_window() where in the code shall I place it not to have any issue?
I comment out the above line in two points in the code and now the applet and panel run smoothly .Thanks again.

About subprocess.Popen(["./"]) and os.path.dirname(os.path.abspath(__file__)) how to write the code I mean how to use both of them so the file runs from the applets dir.

That would be something like:

ownpath = os.path.dirname(os.path.abspath(__file__))
subprocess.Popen(os.path.join(ownpath, ""))

looking at that: import os.path is a bit redundant, since you already did import os.

Got it.
Thanks a lot again.