This is the situation:
Working on (the next version of) a Unity Quick List editor, I would like to add a reliable way of "restarting" launcher icons. To do so, I need to remove the icon (editing gsettings) and replace it on the same position. So far no problem. However, if the application in question is running, user will possibly lose data, as the application will quit when it's icon is removed from the launcher. What I need is a reliable way to find an application's process name, to let the editor check in the list of running processes if the application is running, and send a warning message to the user that the icon can not be restarted if the application is running.
What I did so far is make the editor look into the desktop file, to read the command, also read the command, stripped from the directory section, and furthermore look into possible remote scripts the desktop file command might refer to, looking for strings starting with "./"
Although the method seems to work well with all applications I tested it on, I have the feeling there must be an easier way to cover the problem in an "all in one" way...
Is there?
Also suggestions to catch more exceptional situations are welcome!
ps
andxprop
output ?.desktop
file, which is not necessarily the WM_CLASS. The WM_CLASS can be set from within the application.firefox.desktop
, it launches firefox with PID 1234, but changedWM_CLASS
to something like 'Totally Not Firefox'. The.desktop
file however doesn't change. You want to get the name attached to PID 1234 regardless ofWM_CLASS
. I think I see exactly what needs to be done. But you didn't answer my first question - is it OK if it's only for Unity ?