The Xfce menu is automatically generated, creating or removing entries as applications are installed or uninstalled. While convenient, many users want to customize their menus and are dismayed to find that Xfce’s menu editor is of no help in modifying these automatic entries (the so-called “system” portion of the menu).
Common advice is to deactivate the automatic generation of the menu. While effective, the cure is perhaps worse than the disease: the user is condemned to forevermore update the menu by hand. Newly installed applications will no longer appear automatically, nor will newly uninstalled apps have their menu entries removed.
But you can have your cake and eat it too: retain automatic generation of the menu, yet still have full manual editing control over it. Here’s how.
The Xfce menu follows the desktop menu specification of freedesktop.org (see references), automatically populating the menu with information found in desktop information files of the form “application.desktop”. System wide, most desktop files are found in /usr/share/applications/. Most per user files (which override system wide files) can be found in ~/.local/share/applications/.
First decide if you want to modify a menu entry system wide or per user. System wide entries will be overwritten upon each fresh system installation, and per user entries should be saved as part of your regular backup plan, so modifying per user entries is usually the best decision for a single user workstation. If you are modifying system wide entries, you will need to perform what follows as root.
Search for an appropriate .desktop file for the menu entry you wish to modify and open it in the editor of your choice. locate is a good command line tool for this. For example, to find the .desktop file for the application kcalc:
$ locate .desktop | grep -i kcalc /usr/share/applications/kde/kcalc.desktop
The .desktop file usually has the name of the binary executable of the application, as in the example above. This is not always so, however (e.g. kde-kpdf.desktop) so it is good practice to have locate search for “.desktop” and grep the output for the name of the binary executable of the application, as above. The -i switch is used to avoid problems with case (e.g., Konqueror.desktop).
Notice that the file in the example above is not in the usual place for a system file, which is another reason to use locate. Being a system file, you will have to be root to edit it. If you plan to copy it to a per user directory, be sure to do this as the user, not as root, or you will have a file owned by root, which would be a minor annoyance the next time you want to modify it. Thus:
$ cd ~/.local/share/applications/ $ cp /usr/share/applications/kde/kcalc.desktop .
Notice the trailing dot, to copy it to your current directory. Then open it for editing as user with your favorite editor.
The .desktop file format is documented at freedesktop.org, but the format is mostly self-explanatory. The keys you will most likely want to modify are:
Name to appear on menu.
Path to executable binary.
Categories in which the entry should be shown in a menu. The most commonly used values are AudioVideo (which corresponds to Xfce’s category “Multimedia”), Development, Education, Game, Graphics, Network, Office, Settings, System (which corresponds to Xfce’s category Tools – System Tools), and Utility (which corresponds to Xfce’s category “Accessories”).
There are many other keys available. Some others you may find useful include:
Path to xpm or png format icon to display on the menu. See /usr/share/pixmaps/ and /usr/share/icons/ for useful icons installed on your system. TODO: Under certain circumstances, only the name of the binary is required; discover why and document.
Only shows the entry in one or more particular environments, separated by semicolons. Useful for environment-specific applications, such as the Xfce Settings Manager Xfce-setting-show. Valid values are XFCE, KDE, GNOME, ROX (case sensitive). TODO: Does not always work; discover why and document.
Does not show the entry in one or more particular environments. Valid values are same as above. TODO: Does not always work; discover why and document.
Means “this application exists, but don’t display it in any environment’s menu”. Since .desktop files are used for more than just generating menus, use this key instead of deleting the .desktop file if you do not want a menu entry in any environment. Valid values are true, false. TODO: Does not always work; discover why and document.
Make your changes to the .desktop file, save your changes, and wait a moment for Xfce to recreate its menu. On my system, 5 seconds is sufficient; your mileage may vary. Open the menu and check that all is as expected.
- A per user file is taking precedence over the system wide file you are editing.
- The per user file you are editing contains an error, causing Xfce to fall back to the system wide file.
- Spelling errors.
- Path errors. The Exec key in particular is prone to this. Relative paths do not work, so unless the referenced file is in the user’s $PATH, use the full, absolute path. Thus “~/cxoffice/bin/iexplore” fails but “/home/user/cxoffice/bin/iexplore” works.
- Defective Categories values. For example, upon installation, kcalc did not appear on the Xfce menu. kcalc.desktop had “Categories=Office;Qt;KDE;Utility;X-KDE-Utilities-Desktop”. Deleting the “X-KDE-Utilities-Desktop” portion caused it to appear.
- The keys “OnlyShownIn” and “NotShownIn” should be spelled thusly. They are documented by freedesktop.org as “OnlyShowIn” and “NotShowIn”, but that spelling does not work in Xfce. TODO: Confirm this.
- Boolean values, such as those taken by “NoDisplay”, must not have a trailing semicolon.
- Sometimes you have to re-save the file, even though it has already been saved. Make a trivial change to the file, undo it, and save the file.