Given the path to an executable (say
/usr/bin/gvim), how can I find the Gnome .desktop file for that application?
I'm futzing around in python, so a python-specific answer would be most helpful.
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
If you want to do it programmatically, use python-gmenu. It wraps the libgnome-menu2 API for Python.
That API lets you iterate over all the desktop directories that are currently configured and includes any overrides or modifications the user has customized. Then you just query each file to see if it's Exec line matches what you expect.
I couldn't find any documentation for either library, but liberal use of "import gmenu; dir(gmenu)" and looking over /usr/include/gnome-menus/gmenu-tree.h should help.
If your package is installed from package (not from source), you can use (in Bash):
dpkg -L $(dpkg -S /usr/bin/pidgin | cut -f1 -d: ) | grep \.desktop$
In the case of
gvim, it outputs nothing. You have another problem, in fact,
gvim is an alternative. The "true"
gvim can be multiple programs. On my computer it is
/usr/bin/vim.gnome. Let's try with it. This doesn't work either... because there is no
.desktop in the same package that
vim.gnome. In fact, in this complicated case, the
.desktop is in another package common to all graphical interfaces of Vim: