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.
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.
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: vim-gui-common
The .desktop files for most applications are stored in:
/usr/share/applications
some .desktop files may also be stored in:
/usr/local/share/applications
or (for per user settings) in:
~/.local/share/applications
You can search through all desktop files. For example, to find the desktop file related to gedit
:
grep -li exec=gedit $(locate -r '\.desktop$')
You can execut 1.sudo find /path_to_folder/ -iname *.desktop
in general. And 2.sudo find / -iname *.desktop
in your case.