Xfce Wiki

Sub domains
 

This is an old revision of the document!


Tilpas menuen i Xfce

Denne side beskriver hvordan du tilpasser menuen under brug af xfcesktop 4.5 eller højere og libxfce4menu til dit skrivebord. Bemærk, at der ikke findes en grafisk menuredigering til 4.6. Vi håber den vil komme tilbage i 4.8.

Hvad installerer xfdesktop

Xfdesktop installerer en menufil samt skrivebordsposter til menuen root (Kør, Terminal, Filhåndtering, …). For at tilpasse din menu skal du ændre disse.

Redigér menufilen

Opret mappe ~/.config/menus (hvis denne ikke findes allerede):

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

Kopiér den installerede til din hjemmemappe:

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

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 …