Xfce Wiki

Sub domains
 

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
howto:customize-menu [2010/07/20 12:56] 84.223.128.1howto:customize-menu [2022/09/19 22:24] (current) – Update dead link kevinbowen
Line 1: Line 1:
 ====== Customize the Xfce menu ====== ====== Customize the Xfce menu ======
  
-This page describes how to customize the menu, using Xfdesktop **4.5 or higher** and libxfce4menu, for your desktopNote that in 4.6 there is no graphical menu editor. We hope that it will be back for 4.8.+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, [[http://lxmed.sourceforge.net|LXMenuEditor]], also works for Xfce, as of Xfce 4.8.0 and LXMenuEditor 20110523. [[https://launchpad.net/menulibre|MenuLibre]] is another freedesktop.org standard-compliant editor that works well with Xfce. 
 + 
 +----
  
 ===== What xfdesktop installs ===== ===== What xfdesktop installs =====
-Xfdesktop installs a menu fileand desktop entry files for the root menu (ExecuteTerminal, File manager, …).  To customize your menu you will have to tweak those.+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 nullso ~/.config/menus/xfce-applications.menuand 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.
  
-===== Edit the menu file ===== 
 Create ~/.config/menus directory (if it doesn't exist already): Create ~/.config/menus directory (if it doesn't exist already):
   mkdir ${XDG_CONFIG_HOME:-~/.config}/menus/   mkdir ${XDG_CONFIG_HOME:-~/.config}/menus/
-Copy the installed menu inside your home:+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   cp $prefix/etc/xdg/menus/xfce-applications.menu ${XDG_CONFIG_HOME:-~/.config}/menus
-===== Hide root entries ===== +or 
-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 [[http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s05.html|here]].+  cp $prefix/etc/xfce/xdg/menus/xfce-applications.menu ${XDG_CONFIG_HOME:-~/.config}/menus
  
-Xfdesktop installs the following desktop entry files+[[|Back to Top]] 
-($prefix = /usr for most users)+---- 
 + 
 +===== 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. 
 + 
 +<note tip>As explained[[http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s05.html| 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.</note> 
 +===== 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-about-xfce.desktop''
Line 25: Line 55:
   * ''$prefix/share/applications/xfce4-web-browser.desktop''   * ''$prefix/share/applications/xfce4-web-browser.desktop''
  
-To hide a specific desktop entry file, copy it inside //.local/share/applications// directory in your homefor example:+For example, to remove Web Browser from the root menu, copy its .desktop file and edit itchanging ''Categories=X-XFCE;X-Xfce-Toplevel;'' to ''Categories=X-XFCE;''
  
-  cp $prefix/share/applications/xfce4-web-browser.desktop ~/.local/share/applications +[[|Back to Top]] 
- +----
-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 === +
-{{wiki:warning.png |}} 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'':+
  
 +===== 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]   [Desktop Entry]
   Version=1.0   Version=1.0
Line 55: Line 73:
   Name=Eclipse   Name=Eclipse
   Comment=Eclipse Java IDE   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.
  
-In order for this to show upyou have to modify ''${XDG_CONFIG_HOME:-~/.config}/menus/xfce-applications.menu'', for example: +The categories determine where the new entry will be displayed. For display in the root menuinclude 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:
 <code xml> <code xml>
-  <Menu> +    <Menu> 
-    <Name>Xfce</Name> +        <Name>Accessories</Name> 
- +        <Directory>xfce-accessories.directory</Directory
-    <DefaultAppDirs/> +        <Include> 
-    <DefaultDirectoryDirs/> +            <Or> 
- +                <Category>Accessibility</Category> 
-    <Include> +                <Category>Core</Category
-        <Category>X-Xfce-Toplevel</Category> +                <Category>Legacy</Category
-    </Include+                <Category>Utility</Category
- +            </Or
-    <Layout+        </Include> 
-        <Filename>xfce4-terminal.desktop</Filename+    </Menu>
-        <Separator/> +
-        <Filename>eclipse.desktop</Filename> +
-     +
-    [...]+
 </code> </code>
 +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''.
  
 +----
  
-===== Edit entries ===== +===== 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.
-Starting from version 4.5libxfce4menu 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.+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.
  
-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/%%''.+[[|Back to Top]] 
 +----
  
-===== Create submenus ===== +===== Create sub-menus ===== 
-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:+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:
  
 <code xml> <code xml>
Line 123: Line 141:
   Comment=home displayed in Thunar   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. +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.
- +
-===== 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.+===== Forcing changes ===== 
 +This is not usually necessary and may not work anyway; logging out of the Xfce session and back in always works
  
-Enjoy!+If the menu is not automatically updated with your changes, try 
 +  xfdesktop --reload 
 +If that doesn't work, try 
 +  killall -HUP xfdesktop
  
-===== What, if it does not work? ===== +[[|Back to Top]] 
-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/)+===== Questions ===== 
 +==== Answered ====
  
-where do i find a log or anything like that, actually giving me a clue other than simply empty space in the menu?+**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 ...
  
-A XFCE Lover that's got very upsetI 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.+**Question:** Primarily i wanted to modify the menu-structureJust 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.
  
-AnswerIn 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 alsoI have no appropriate machine to compare. +**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? 
-Also note, that you should not only extend your Layout-Section but also your Include-Section ...+**Answer:** NoThe menu file defines which categories of entry go whereYour 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.
  
-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. +[[|Back to Top]] 
 +----
  
 +==== Unanswered ====
  
-want to add an entry for an application that's installed by hand, rather than through the package managerIf I make a local copy of /etc/xdg/xubuntu/menus/xfce-applications.menu, then when I add further application using the package managerwon't it change only the master ? Will I have to re-copy and re-edit ?+  * With which command can 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 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 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 promptyou 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.
  
-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 ...+  * 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]]
 +----
 +[[https://docs.xfce.org/xfce/xfce4-panel/start|Back to xfce4-panel main page]]