determine an application's process name on linux (ubuntu)

Posted by Jacob on Ask Ubuntu See other posts from Ask Ubuntu or by Jacob
Published on 2012-12-15T08:36:04Z Indexed on 2012/12/15 11:22 UTC
Read the original article Hit count: 117

Filed under:
|
|
|

This is the situation: Working on (the next version of) a Unity quicklist 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 te 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!

© Ask Ubuntu or respective owner

Related posts about unity

Related posts about launcher