Xfce Wiki

Sub domains

This is an old revision of the document!

自定义 Xfce 菜单

此页介绍如何在4.5或更高版本 Xfdesktop 上自定义菜单。对于早期版本,您可以使用 libxfce4menu 的 GUI。

GNU 许可的 LXDE 的图形菜单编辑器 LXMenuEditor ,从 Xfce 4.8.0和LXMenuEditor 20110523 起,它也可以用于 XFCE 了。

xfdesktop 会安装什么文件

Xfdesktop 会安装菜单文件和 .desktop 文件以及一些定义菜单的非 xfdesktop 的 .desktop 文件。自定义菜单就需要修改这些文件。这里描述修改的菜单文件由环境变量 $XDG_CONFIG_HOME 确定(通常为空,所以是 ~/.config/menus/xfce-applications.menu)和一些你的主目录中 .desktop 文件。


当 xfdesktop 会话启动时,如果菜单文件的目录存在,修改立即生效。同样地,当 xfdesktop 会话启动时,如果你主目录中的 .local/share/applications 目录存在的话,对 .desktop 文件的修改也立即生效。



创建 ~/.config/menus 目录(如果还不存在):

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

复制已安装的菜单文件到先于默认安装的菜单文件路径的 xfdesktop 查找的路径中(在大多数系统上 $prefix = /usr)。

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


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

复制 .desktop 文件

例如,要复制Web浏览器的 .desktop 文件到主目录中的 .local/share/applications 目录 (在大多数系统上 $prefix = /usr):

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


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


如果你想隐藏菜单项,复制他的 .desktop 文件,编辑并添加一行 NoDisplay=true

的解释,NoDisplay=true 会在菜单上隐藏程序,但 mime 类型的关联仍然存在。Hidden=true 等价于删除这个文件。


如果你只想删除根菜单项,复制它们的 .desktop 文件,编辑并删除 X-Xfce-Toplevel Category。

Xfdesktop 默认会安装下面这些根菜单项(在大多数系统上 $prefix = /usr):

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

例如,把Web浏览器从根菜单中删除,复制它的 .desktop 文件,编辑并修改 Categories=X-XFCE;X-Xfce-Toplevel;Categories=X-XFCE;


为每个菜单项创建一个 .desktop。例如,一个 Eclipse 的菜单项,在 ~/.local/share/applications中创建文件 eclipse.desktop

[Desktop Entry]
Comment=Eclipse Java IDE

如果你喜欢用 GUI 工具(可以浏览选择图标),你可以用下面的命令创建 .desktop 文件

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

但这样新建的文件类别(Category)里面只有 Application, 可能需要再编辑才行。

类别(Category)决定菜单项会显示在哪。要在根菜单中显示,添加 X-Xfce-Toplevel 类别。要在子菜单中显示,添加至少一个已定义的子菜单类别。这个可以在 ${XDG_CONFIG_HOME:-~/.config}/menus/xfce-applications.menu 文件中找到。例如这是一个“附件”菜单的定义:


任何包含 Accessibility, Core, Legacy 及 Utility 类别的并没有 NoDisplay=true 的 .desktop 文件都会显示在“附件”菜单下。

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.

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:


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

[Desktop Entry]
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]
Exec=/usr/local/bin/thunar /usr/home/yourname
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



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.


  • 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?
  • 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 …