How to xfce 4.6 menu edit in Xubuntu 9.04 – Jaunty

I mithered on about this a bit in my last post, but after some searching and fiddling about, got to where I wanted to go. It didn’t help that on the xfce wiki a missing “/” in the code for copying a file meant any changes I made just didn’t work..

With xfce 4.6 you have the so called freedesktop.org standard for menus. I only use the right click on the desktop menu (and this will be my focus) that brings up a whole pile of extra stuff you only occasionally need, and seems to take for every to browse through the menu and sub-menu structure to find your app. The menu editor that was in earlier versions has disappeared, hopefully to come back in 4.8, but that is some time away.

The fixes and edits come in two parts.

  1. Remove the extra guff from the right click menu, but have it available if you need it
  2. Remove items, add items and reduce excess on the main applications menu

1.  Remove the extra guff from the right click menu, but have it available if you need it

All credit goes to mrprimrose on the Zenwalk forums for this one, which is a small script that turns the extra stuff on and off (using the same script). Here is the script, just copy it to a file and make executable, create a launcher (I have one on my wbar) and it’s job done.

#!/bin/bash
MENU=$(xfconf-query -c xfce4-desktop -v -lp /desktop-icons/style | cut -d” ” -f3)
echo $MENU
if [ $MENU -eq 0 ]
then
NMENU=2
else
NMENU=0
fi
echo $NNEW
xfconf-query -c xfce4-desktop -v -p /desktop-icons/style -s $NMENU

I attach as a zip too xfce desktop menu changer

So here are the results, the first without the change, and the second with:

Original Menu      New Look

You’ll have to agree, its a big improvement. Just run the script again from your launcher when you need access to the full menu. if you were clever you could add it to the menu itself (see part 2).

2.  Remove items, add items and reduce excess on the main applications menu

The menu structure and what you see is governed by three areas; what’s in the xfce-applications.menu file, what is contained within each of the .desktop configuration files for applications, and your settings for desktop icons. I suggest you don’t play with the root versions of either of the first two, but as you will see, to copy them across to your home directory, so you can make changes on a per user basis.

a. Copy over and configure the menu file

 mkdir ~/.config/menus

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

Now open up the file in your favourite text editor

mousepad ~/.config/menus/xfce-applications.menu

and you will get some thing like this:

<!DOCTYPE Menu PUBLIC “-//freedesktop//DTD Menu 1.0//EN”
http://www.freedesktop.org/standards/menu-spec/1.0/menu.dtd“>

<Menu>
<Name>Xfce</Name>

<DefaultAppDirs/>
<DefaultDirectoryDirs/>

<Include>
<Category>X-Xfce-Toplevel</Category>
</Include>

<Layout>
<Filename>xfce4-run-program.desktop</Filename>
<Separator/>
<Filename>xfce4-term.desktop</Filename>
<Filename>xfce4-file-manager.desktop</Filename>
<Filename>xfce4-web-browser.desktop</Filename>
<Separator/>
<Menuname>Settings</Menuname>
<Separator/>
<Merge type=”all”/>
<Separator/>
<Filename>xfce4-help.desktop</Filename>
<Filename>xfce4-about-xfce.desktop</Filename>
<Filename>xfce4-logout.desktop</Filename>
</Layout>

<Menu>
<Name>Settings</Name>
<Directory>xfce-settings.directory</Directory>
<Include>
<Category>Settings</Category>
</Include>

<Layout>
<Filename>xfce-settings-manager.desktop</Filename>
<Separator/>
<Merge type=”all”/>
</Layout>

<Menu>
<Name>Screensavers</Name>
<Directory>xfce-screensavers.directory</Directory>
<Include>
<Category>Screensaver</Category>
</Include>
</Menu>
</Menu>

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

<Menu>
<Name>Development</Name>
<Directory>xfce-development.directory</Directory>
<Include>
<Category>Development</Category>
</Include>
</Menu>

<Menu>
<Name>Education</Name>
<Directory>xfce-education.directory</Directory>
<Include>
<Category>Education</Category>
</Include>
</Menu>

<Menu>
<Name>Games</Name>
<Directory>xfce-games.directory</Directory>
<Include>
<Category>Game</Category>
</Include>
</Menu>

<Menu>
<Name>Graphics</Name>
<Directory>xfce-graphics.directory</Directory>
<Include>
<Category>Graphics</Category>
</Include>
</Menu>

<Menu>
<Name>Multimedia</Name>
<Directory>xfce-multimedia.directory</Directory>
<Include>
<Category>Audio</Category>
<Category>Video</Category>
<Category>AudioVideo</Category>
</Include>
</Menu>

<Menu>
<Name>Network</Name>
<Directory>xfce-network.directory</Directory>
<Include>
<Category>Network</Category>
</Include>
</Menu>

<Menu>
<Name>Office</Name>
<Directory>xfce-office.directory</Directory>
<Include>
<Category>Office</Category>
</Include>
</Menu>

<Menu>
<Name>System</Name>
<Directory>xfce-system.directory</Directory>
<Include>
<Category>System</Category>
</Include>
</Menu>

<Menu>
<Name>Other</Name>
<Directory>xfce-other.directory</Directory>
<OnlyUnallocated/>
<Include>
<All/>
</Include>
</Menu>

</Menu>

I have emboldened the part we are immediately interested in.

So here is the default:

<Layout>
<Filename>xfce4-run-program.desktop</Filename>
<Separator/>
<Filename>xfce4-term.desktop</Filename>
<Filename>xfce4-file-manager.desktop</Filename>
<Filename>xfce4-web-browser.desktop</Filename>
<Separator/>
<Menuname>Settings</Menuname>
<Separator/>
<Merge type=”all”/>
<Separator/>
<Filename>xfce4-help.desktop</Filename>
<Filename>xfce4-about-xfce.desktop</Filename>
<Filename>xfce4-logout.desktop</Filename>
</Layout>

and this is what I edited it down to:

<Layout>
<Merge type=”all”/>
<Separator/>
<Menuname>Settings</Menuname>
<Separator/>
<Filename>xfce4-logout.desktop</Filename>
</Layout>

To refresh your desktop to get the settings to take effect try:

xfdesktop –reload

if that doesn’t work:

killall -HUP xfdesktop

This should tidy things up a lot, see the results but some icons ans listings may still be showing. You will need to do some more file editing to sort these out.

b. Edit desktop files.

Lets choose an example. After the changes I made above, the Web Browser reappeared. So i copied over the desktop configuration file for web browser and edited it to stop it from showing up.

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

mousepad  ~/.local/share/applications/xfce4-web-browser.desktop

You’ll get this (truncated to remove all the locale info)

[Desktop Entry]
Version=1.0
Type=Application
Encoding=UTF-8
Exec=exo-open –launch WebBrowser %u
Icon=web-browser
StartupNotify=false
Terminal=false
Categories=X-XFCE;X-Xfce-Toplevel;
OnlyShowIn=XFCE;
Name=Web Browser
Name[ar]=مستعرض الوب
Name[az]=Veb Səyyahı

[…]

You can stop it from showing up by adding “NoDisplay=true” to the file. I added this above the names:

[Desktop Entry]
Version=1.0
Type=Application
Encoding=UTF-8
Exec=exo-open –launch WebBrowser %u
Icon=web-browser
StartupNotify=false
Terminal=false
Categories=X-XFCE;X-Xfce-Toplevel;
OnlyShowIn=XFCE;
Nodisplay=true
Name=Web Browser
Name[ar]=مستعرض الوب
Name[az]=Veb Səyyahı

[…]

Save out, reload xfdesktop, and the entry should be gone. You will also see there is a categories listing. This tells the menu where to show an entry. So in this example of the Mousepad desktop file, you can see it has the category of “Utility”, which if you look at the sub menu structure, sits under Accessories.

[Desktop Entry]
Version=1.0
Type=Application
Encoding=UTF-8
Name=Mousepad
[…]
Exec=mousepad %f
Icon=mousepad
StartupNotify=true
Terminal=false
MimeType=text/plain
Categories=Application;Utility;TextEditor;GTK;

You can play around with these all day :) moving categories adding or removing entries. Remember to do all this in your home, and back up any files you might be worried about. Again, because my most accessed apps are on the wbar, I rarely have need for the right click menu, but I needed to know how to configure it, given it was so easy to do in Openbox!

3 thoughts on “How to xfce 4.6 menu edit in Xubuntu 9.04 – Jaunty

  1. Thank you for this article. I ran into the same problem after I updated my xfce. ./xfdeskmenu.sh dosn’t work on gentoo but the code mrprimrose mentioned does.

    Here it is – thanks for your link
    xfconf-query -c xfce4-desktop -p /desktop-icons/style -s 2 (ON)
    xfconf-query -c xfce4-desktop -p /desktop-icons/style -s 0 (OFF)

  2. Thanks for that, just upgraded to 9.04, and the lack of custom menu is the last thing to get sorted.
    I have followed your directions and have simplified the right-click menu from desktop.
    ie. removing the xfce application menu

    But have you any idea how to edit the rest of the desktop menu ?
    I dont see much of a use for the menu items that are present for the way I use my desktop, and it just seems a waste of a menu…

  3. Can you post a kommander-gui-script-version of this article for download? I don’t wanna create new user accounts and edit n’ copy three different configuration-files. Thank you.

Leave a Reply

Your email address will not be published. Required fields are marked *