Howto: Create Custom Entries in Gnome/KDE/XFCE/LXDE/Etc's Menu

Years ago, you used to be able to add entries to Gnome's "start" menu by opening an easy to use program to edit the menu entries. Unfortunately they decided to change the API and most other environments followed suit, without ever bothering to create an updated tool for ordinary users to update the menu with. If one exists now that actually works i have never seen it. This post documents a relatively easy way to gain the same functionality without a silly broken gui in the way.

DISCLAIMER: I have only tested this with XFCE and LXDE in Debian Testing and some old Ubuntu version I used to have, Gnome should be the same although I have not tested it, and i cannot stand KDE enough to bother installing it long enough to test it, but I presume it works the same way. Other distros should also work similarly, but no guarantees.

1. Navigate to /home/user/.local/share/applications, you should see a few files with icons there. Those are .desktop files, which you can open in any plain text editor.

2. Create a new blank file and name it application.desktop, where application is the name of the application you wish to link to. It is not particularly important what it is named, although it is a good idea to name it the same as what you are linking to.

3. Open the .desktop file you just created in your plain text editor of choice (i used leafpad) and enter a block of text similar to this:
[Desktop Entry]
Type=Application
Name=Firefox
Comment=Mozilla Firefox
GenericName=Web Browser
Icon=/home/username/firefox/chrome/icons/default/default48.png
Exec=/home/username/firefox/firefox
Terminal=false
Categories=GTK;Network;WebBrowser;

4. Edit the block of text to fit your application, The full spec is here: http://standards.freedesktop.org/desktop-entry-spec/latest/ but you can use this as a rough guide:
Type = not sure what types there are besides Application
Name = the name of the application as you want shown as the shortcut name (not necessarily the same as the *.desktop name)
Comment = shown when you put your mouse pointer over it, probably optional
Generic Name = a generic short description, probably optional
Icon = the icon you want to use, can be of any format the system supports, i prefer .xpm and .png
Exec = the executable path (last part is the actual executable name, can be a shell script)
Terminal = determines wether or not you want it to output to a terminal window, useful for debugging
Categories = the categories you want it to show up in in gnome/kde/xfce/lxde/etc's menu

5. Save the file and check your window manager's menu, there should now be an entry for the application you just created a shortcut for and it should launch the application when you click it.

PROTIP:
use 'sudo locate *.desktop' in a terminal to find other .desktop files as examples of what is possible. generally you want to use an example that most closely resembles what you want to link to, in my case i used an existing browser .desktop file to create the firefox one. Also, shoot at it until it dies.

Disreguard any spelling, capitalization, and/or grammar mistakes. Blogger's spellcheck is broken in Mozilla Aurora builds and I cannot be bothered to use Chromium just to post here.

Edit: found the link to the spec just after I posted initially, my bad.
Post a Comment