Xfce Wiki

Sub domains
 

This is an old revision of the document!


Customize the Xfce menu

This page describes how to customize the menu, using Xfdesktop 4.5 or higher and libxfce4menu, for your desktop. Note that in 4.6 there is no graphical menu editor. We hope that it will be back for 4.8.

What xfdesktop installs

Xfdesktop installs a menu file, and desktop entry files for the root menu (Execute, Terminal, File manager, …). To customize your menu you will have to tweak those.

Edit the menu file

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

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

Copy the installed menu inside your home:

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

Hide root entries

If you choose to remove menu items out from the root menu, you have to copy the specific desktop entry files to your home, and then add/change the NoDisplay entry key inside it. More information about the recognized desktop entry keys can be found here.

Xfdesktop installs the following desktop entry files: ($prefix = /usr for most users)

  • $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

To hide a specific desktop entry file, copy it inside .local/share/applications directory in your home, for example:

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

and then modify or add the desktop entry key NoDisplay:

NoDisplay=true

Don't forget to reload the menu! (See section above)

Difference between NoDisplay and Hidden

If you've looked at the desktop entry file spec, you may have already noticed the difference between these two entry keys. NoDisplay will hide the application from the menu but the mime type associations will still be read by Thunar (for instance). Setting the Hidden entry key to true acts the same as deleting the file.

Create root entries

Your own menu items go to ~/.local/share/applications.

In there, you can create standard desktop file entries per menu item, eg. for a menu item launching 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

In order for this to show up, you have to modify ${XDG_CONFIG_HOME:-~/.config}/menus/xfce-applications.menu, for example:

  <Menu>
    <Name>Xfce</Name>
 
    <DefaultAppDirs/>
    <DefaultDirectoryDirs/>
 
    <Include>
        <Category>X-Xfce-Toplevel</Category>
    </Include>
 
    <Layout>
        <Filename>xfce4-terminal.desktop</Filename>
        <Separator/>
        <Filename>eclipse.desktop</Filename>
 
    [...]

Edit entries

Starting from version 4.5, libxfce4menu doesn't support “Merge” from the menu specification. This means that it is not possible to build a nice menu editor. In order to add/remove or edit menu entries you have to copy the files manually.

Say that “gvim” is installed, you should have the desktop entry file /usr/share/applications/gvim.desktop. Copy that file to your home directory in ~/.local/share/applications. Then you can modify it.

To create new menu items, you can create new desktop entry files inside that latter directory. exo-desktop-item-edit eases the creation of such a file. For instance run exo-desktop-item-edit --create-new ~/.local/share/applications/.

Create submenus

To create a new submenu, add a new “Menu” element to your ~/.config/menus/xfce-applications.menu at the same level as the other XFCE submenus 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 submenu. 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, and after refreshing the menu if needed (see below), you should have a new submenu called “Folders” using the file manager icon. Daisen 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.

Reload the menu

If you don't have file monitoring support, run

''%%xfdesktop --reload%%'' 

to refresh the menu.

If the above does not work, you might also try to run

''%%killall -HUP xfdesktop%%'' 

instead.

Enjoy!

What, if it does not work?

questions unanswered:

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/)

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

A XFCE Lover that's got very upset. 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 …

Primarily i wanted to modify the menu-structure. Just copying xfce-applications.menu to my home did'nt 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 did'nt work either. Modifying Menu-Entries was ok but changes to the structure of the menu-file had no effect.

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 ?

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 …