Xfce Wiki

Sub domains
 

Customize the Xfce menu

This page describes how to customize the menu, using Xfdesktop 4.5 or higher. For earlier versions you can use the libxfce4menu GUI.

A GNU-licensed graphical menu editor for LXDE, LXMenuEditor, also works for Xfce, as of Xfce 4.8.0 and LXMenuEditor 20110523. MenuLibre is another freedesktop.org standard-compliant editor that works well with Xfce.


What xfdesktop installs

Xfdesktop installs a menu file and .desktop files which together with non-xfdesktop .desktop files define the menu. To customize your menu you need to modify them. The method described here modifies the menu file identified by the $XDG_CONFIG_HOME variable (usually null, so ~/.config/menus/xfce-applications.menu) and copies of .desktop files in your home directory.


When xfdesktop implements your changes

If the menu file's directory exists when the xfdesktop session starts, changes to the menu file are implemented immediately. Similarly if the .local/share/applications directory in your home directory exists when the xfdesktop session starts, changes to its .desktop files are implemented immediately.


Copy the menu file

This is only necessary if you want to change the hardcoded entries (usually above the Settings sub-menu and below the last sub-menu) or to change the sub-menu definitions.

Create ~/.config/menus directory (if it doesn't exist already):

mkdir ${XDG_CONFIG_HOME:-~/.config}/menus/

Copy the installed menu file to where xfdesktop will look for it before looking for the installed menu file ($prefix = /usr on most systems):

cp $prefix/etc/xdg/menus/xfce-applications.menu ${XDG_CONFIG_HOME:-~/.config}/menus

or

cp $prefix/etc/xfce/xdg/menus/xfce-applications.menu ${XDG_CONFIG_HOME:-~/.config}/menus

Back to Top


Copy a .desktop file

For example, to copy the Web Browser's .desktop file to the .local/share/applications directory in your home directory ($prefix = /usr on most systems):

cp $prefix/share/applications/xfce4-web-browser.desktop ~/.local/share/applications 

or

cp /usr/share/applications/xfce4-web-browser.desktop ~/.local/share/applications

Hide menu entries

If you want to hide menu entries from all menus, copy their .desktop files and edit them to add a NoDisplay=true line.

As explained here, NoDisplay=true will hide the application from the menu but the mime type associations will still be available. Hidden=true is equivalent to deleting the file.

Hide only root entries

If you only want to remove menu items from the root menu only, copy their .desktop files and edit them to remove Category X-Xfce-Toplevel.

Xfdesktop installs the following desktop entry files in the root menu ($prefix = /usr on most systems):

  • $prefix/share/applications/xfce4-about-xfce.desktop
  • $prefix/share/applications/xfce4-file-manager.desktop
  • $prefix/share/applications/xfce4-help.desktop
  • $prefix/share/applications/xfce4-logout.desktop
  • $prefix/share/applications/xfce4-run-program.desktop
  • $prefix/share/applications/xfce4-terminal.desktop
  • $prefix/share/applications/xfce4-web-browser.desktop

For example, to remove Web Browser from the root menu, copy its .desktop file and edit it, changing Categories=X-XFCE;X-Xfce-Toplevel; to Categories=X-XFCE;

Back to Top


Add entries

Create a .desktop file for each entry required. For example, a menu entry for Eclipse, create a file named eclipse.desktop in ~/.local/share/applications:

[Desktop Entry]
Version=1.0
Type=Application
Encoding=UTF-8
Exec=eclipse
Icon=eclipse
StartupNotify=false
Categories=X-XFCE;X-Xfce-Toplevel;
OnlyShowIn=XFCE;
Name=Eclipse
Comment=Eclipse Java IDE

If you prefer to work in a GUI (allows browsing for the icon) you can create the .desktop file using

exo-desktop-item-edit --create-new ~/.local/share/applications

but the new file will only have category Application so will probably need editing afterwards.

The categories determine where the new entry will be displayed. For display in the root menu, include category X-Xfce-Toplevel. For display in a sub-menu, include at least one of the categories defined for that sub-menu. These can be found by examining your ${XDG_CONFIG_HOME:-~/.config}/menus/xfce-applications.menu. For example here's an Accessories sub-menu definition:

    <Menu>
        <Name>Accessories</Name>
        <Directory>xfce-accessories.directory</Directory>
        <Include>
            <Or>
                <Category>Accessibility</Category>
                <Category>Core</Category>
                <Category>Legacy</Category>
                <Category>Utility</Category>
            </Or>
        </Include>
    </Menu>

Any .desktop files with categories including Accessibility, Core, Legacy or Utility will be shown in the Accessories sub-menu providing they do not also have NoDisplay=true.


The Other sub-menu

If there are any .desktop files which are configured to be displayed in the xfdesktop menu but do not have any categories which include them in any of the defined menus, the Other sub-menu will be displayed and will display those entries. This applies to .desktop files in the $prefix/share/applications/ directory as well as the ~/.local/share/applications directory.

If you have an Other sub-menu and do not want it, copy the .desktop file and modify its categories so it is included in one of the other sub-menus.

Back to Top


Create sub-menus

To create a new sub-menu, add a new “Menu” element to your ~/.config/menus/xfce-applications.menu at the same level as the other xfdesktop sub-menus like “Graphics” or “Multimedia”. In addition to the aptly named “Name” element, two additional elements are required: first, the “Directory” element is useful to associate the submenu with a desktop entry file which provides, among others, an appropriate icon as we will see shortly. Second, the “Category” element associates .desktop files with this sub-menu. It is recommended to make up a custom category starting with “X-”, which is the prefix of non-standard categories by convention. As an example, we'll create a submenu with entries to display various folders in your favourite file manager. Your new entry should look like this:

  <Menu>
    <Name>Folders</Name>
    <Directory>folders.directory</Directory>
    <Include>
      <Category>X-Folders</Category>
    </Include>
  </Menu>

Next, create ~/.local/share/desktop-directories/folders.directory with the following contents:

[Desktop Entry]
Version=1.0
Type=Directory
Icon=file-manager
Name=Folders
Comment=Folders viewed in a file manager

This provides the displayed name of the subdirectory as well as an appropriate icon.

Finally, create .desktop files in your ~/.local/share/applications folder as shown above to populate the submenu. In order to be displayed in the submenu, add your custom category to the “Categories” list. One of these files, let's call it thunar-home.desktop, might look like this:

[Desktop Entry]
Version=1.0
Type=Application
Exec=/usr/local/bin/thunar /usr/home/yourname
Icon=file-manager
StartupNotify=false
Categories=X-Folders;
OnlyShowIn=XFCE
Name=home
Comment=home displayed in Thunar

With all this in place, you should have a new submenu called “Folders” using the file manager icon. The submenu entry shown above should display your home directory in Thunar. You can of course add more entries as shortcuts to common places like /cdrom, /stick, /, or whatever you see fit.


Forcing changes

This is not usually necessary and may not work anyway; logging out of the Xfce session and back in always works.

If the menu is not automatically updated with your changes, try

xfdesktop --reload

If that doesn't work, try

killall -HUP xfdesktop

Back to Top


Questions

Answered

Question: I setup several machines for my company. After migrating all the software to the new version 9.04 we realized we cannot use the custom menus that points to our software with specific variables. Answer: In Jaunty the appropriate file might be found in /etc/xdg/xubuntu/menus/xfce-applications.menu and not in /etc/xdg/menus/xfce-applications.menu. Everything else should work as described above. Could be any other *buntu-flavor in the path also, I have no appropriate machine to compare. Also note that you should not only extend your Layout-Section but also your Include-Section …

Question: Primarily i wanted to modify the menu-structure. Just copying xfce-applications.menu to my home didn't do it. After tracing around with strace and inotify i finally logged out of xfce and back in. Before that my local copy didnt even get touched. xfdesktop –reload didn't work either. Modifying menu entries was ok but changes to the structure of the menu file had no effect. Answer: Menu file changes are implemented immediately if the menu file's directory exists when the xfdesktop session starts. Any further changes you made after logging out of the Xfce session and back in again should have been reflected in the menu immediately.

Question: I want to add an entry for an application that's installed by hand, rather than through the package manager. If I make a local copy of /etc/xdg/xubuntu/menus/xfce-applications.menu, then when I add a further application using the package manager, won't it change only the master? Will I have to re-copy and re-edit? Answer: No. The menu file defines which categories of entry go where. Your further application will appear in the defined place(s). If not, compare its categories with the categories in the menu file and adjust accordingly. Another possible gotcha is that the .desktop file has an OnlyShowIn or NotShowIn line that does not match Xfce.

Back to Top


Unanswered

  • With which command can I set a start-up-password for an application in the *.desktop file?

One approach would be to remove execution rights for others (chmod o-x filename) and start the command using 'Exec=gksudo filename' (gksudo is included in package gksu - apt-get install gksu). You may need to provide some command line options before the filename to tune the behaviour of gksu. In this way users have to be members of group sudo to start the program, and enter their own password to confirm their identity. You could also make the program owned by a special group, e.g. powerusers (sudo addgroup powerusers), that have execution rights (e.g. chown root:powerusers filename && chmod g+x filename && chmod o-x filename) and then users would have to be a member of group powerusers (adduser someuser powerusers) to start the command after one-time logging in and out of the system to apply the new group membership to their user profile. Users that are not members of that group will simply not be able to run the program at all. If you really want a password prompt, you can also run the program using 'Exec=gksu –user someuser filename' in the .desktop file in order to require someuser's password before running the program. However, running programs as a different user is not generally recommended for more complex programs unless you know how to avoid the side-effects (e.g. different home directory, security policy, etc.).

  • What do i do, if the above does not work? (only xfce's own desktop files are seen, not even the one created with exo-desktop-item-edit, not to speak from common desktop files in both /usr/share/applications/ and ~/.local/share/applications/)

In some cases running update-desktop-database may help. Or directly modify the files in /usr/share/applications.

  • Where do i find a log or anything like that, actually giving me a clue other than simply empty space in the menu?

View /usr/share/applications, ~/.local/share/applications, etc. with Thunar. You should see a plain .desktop file listed for the blank entry, between the clickable icons with fancy names.

  • I run Jaunty and need to make the menu to be multi-level, which, in previous versions I believe, could be achieved by editing '/etc/X11/xdg/xfce4/desktop/menu.xml' and replace style=“simple” with style=“multilevel” in the <include>. How do I do this in Jaunty? I need this because I have certain applications under Wine which have very many start-menu entries and they are all merged into one menulevel, which is really annoying to navigate thru. Please help …

See https://forums.opensuse.org/showthread.php/477258-Flat-menu-in-xfce

Back to Top


Back to xfce4-panel main page