Sie sind auf Seite 1von 13

How to customize XFCE menu

First of all, this tutorial is based on the Debian derivative distribution Dreamlinux 5. To closely follow this tutorial, though, you should temporarily move the le /home/ <username/.cong/menus/xfce-applications.menu elsewhere. The same applies to the directory /home/<username>/.local/share/applications. At the end you can move back those le and directory to their original places. XFCE menu follows freedesktop.org specications, as most major Desktop environments like Gnome and KDE do. XFCEs menu is devided in sections and its organization is kept in an XML le named xfce-applications.menu, residing primarily in /etc/xdg/menus. These are the main sections comprising an XFCE menu: - Name section - three self-contained elements: DefaultAppDirs, DefaultDirectoryDirs and DefaultMergeDirs. - Optional Include and Exclude sections. - Layout section. - Menu section. Being an XML grammar, XFCE's menu starts by declaring its namespace in the form:
<!DOCTYPE Menu PUBLIC "-//freedesktop//DTD Menu 1.0//EN" "http://www.freedesktop.org/standards/menu-spec/1.0/menu.dtd">

Everything that follows the namespace declaration is enclosed by the Menu tag, so XFCEs menu root is:
<Menu> </Menu>

The rst element, that identies the document is then:


<Menu> " <Name>Xfce</Name> </Menu>

Including the three self-contained elements, which describe (somewhere in the system) the default directory for applications (/usr/share/applications), default directory for grouping applications in submenus (/usr/share/desktop-directories) and (I'm not 100% sure) I suspect a combination of /etc/xdg/menus and /home/<username>/.cong/ menus. So, our menu le description grows to this:
<Menu> ! <Name>Xfce</Name> ! <DefaultAppDirs/> ! <DefaultDirectoryDirs/> ! <DefaultMergeDirs/> ! </Menu>

Usually Desktop environments like XFCE have their own categorized applications present at the menu's root. XFCE achieves this by creating a particular category named X-XfceToplevel. So, including this category just after the default self-contained elements and prior to the Layout section grows the menu to this:
<Menu> " <Name>Xfce</Name> " " " <DefaultAppDirs/> <DefaultDirectoryDirs/> <DefaultMergeDirs/>

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

Layout is the tag element that organizes menu the way you like. So, XFCE designers organized the menu in XFCE Desktop this way:
<Menu> " <Name>Xfce</Name> " " " " " " <DefaultAppDirs/> <DefaultDirectoryDirs/> <DefaultMergeDirs/> <Include> " <Category>X-Xfce-Toplevel</Category> </Include

" <Layout> " " <Filename>xfrun4.desktop</Filename> " " <Filename>xfce4-run.desktop</Filename> " " <Separator/> " " <Filename>exo-terminal-emulator.desktop</Filename> " " <Filename>exo-le-manager.desktop</Filename> " " <Filename>exo-mail-reader.desktop</Filename> " " <Filename>exo-web-browser.desktop</Filename> " " <Separator/> " " <Menuname>Settings</Menuname> " " <Separator/> " " <Merge type="all"/> " " <Separator/> " " <Filename>xfhelp4.desktop</Filename> " " <Filename>xfce4-about.desktop</Filename> " " <Filename>xfce4-session-logout.desktop</Filename> " </Layout> " </Menu>

Topmost element in XFCEs menu is Run program application, followed by a separator line. Notice that there are two applications here, described in their respective .desktop les (freedesktop.org specications): xfrun4.desktop and xfce4-run.desktop. If there were these two les in /usr/share/applications, both applications would show there at the top. As I aforementioned these are specic XFCE applications, categorized by the value X-Xfce-

Toplevel in their Categories= class, in their respective .desktop les residing in /usr/ share/applications. Since they are individual applications, not grouped in any submenu, they must be referred to by using the tag pair <Filename></Filename>. Notice that there are two different elements in the entire Layout: <Menuname></ Menuname> and <Merge type="all"/>. The rst is surrounded by two <Separator/> elements and describes the rst instance of submenus in the menu (see gure 1).

Fig, 1 - XFCE Desktop pristine

If you look at the picture with the pristine XFCE menu it will appear exactly the same way: Settings is surrounded by two separators lines and has a right arrow that spans into a submenu. And the <Merge type="all"/> element is responsible to merge all other elements in the menu, no matter if individual les or les grouped by a submenu. That's why you have all those submenus Accessories, Development, Graphics, Internet, Multimedia, Ofce, Other and System, plus About This System, which is a regular Dreamlinux specic application, present in /usr/share/applications. Since it's categorized as a X-Xfce-Toplevel application

(although its a Dreamlinux specic one), and not included in the Layout section, it will appear only by means of <Merge type="all"/> tag. Make a try out: edit /etc/xdg/menus/xfce-applications.menu and comment out <Merge type="all"/> this way: <!-- <Merge type="all"/> --> and you'll nd that the menu changed accordingly (see picture 2). Erasing the comment returns the menu to its original state.

Fig. 2 - Commenting <Merge type="all"/> out

Finally, the last element in the menu structure: the submenus. Submenus are created by enclosing elements between the tags <Menu></Menu>. Yes, the same topmost tag. Submenus are menus afterall. Let's take Settings, the submenu that appears rst, surrounded by separator lines and described by the enclosing <Menuname></Menuname> tag in the Layout section. Its dened this way:
<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</Menu> " " <Directory>xfce-screensavers.directory</Directory> " " <Include> " " " <Category>Screensaver</Category> " " </Include> " </Menu> </Menu>

This arrangement creates the Settings submenu like shown in the next picture.

As you can see in the XML code, the submenu Settings is a complete menu structure in itself, with a Name, a Category to identify its internal elements, a Layout and even an internal submenu. Also notice that, for the rst time a .directory element appears in the menu structure: xfce-settings.directory. This is the element responsible for not only identify an element as a submenu under another menu, but also to name it, show an icon alongside it (to its left) and other interesting stuff, like translations to other locales. As I mentioned before, this specic le (xfce-settings.directory) resides in /usr/share/ desktop-directories. Have a look in it to have an idea. Proceeding, notice that, after being identied by <Name>Settings</Name> and get all its details from <Directory>xfce-settings.directory</Directory>, it includes a Category, named Settings. This means that every application that has "Settings" in its Categories= line somewhere in its denition le (.desktop) in /usr/share/applications will show under the Settings submenu. Specically to the Settings submenu, notice that it layouts itself to have the xfce-settingsmanager application (<Filename>xfce-settings-manager.desktop</Filename>) on its top and a submenu comprised of Screensavers specic applications. If there are screensaver applications, they shall appear under a screensavers submenu that is named and featured at a .directory le in /usr/share/desktop-directories. If theres no screensavers aplications, then this submenu does not appear, although dened. Notice also that, after its top item, it shows a separator (<Separator/>) and all applications categorized as Settings appear bellow it by means of the line <Merge type="all"/>. Setting submenu is an excellent example of a complete menu structure. A simpler submenu item, though, is exactly like this one:
<Menu> " <Name>Development</Name> " <Directory>xfce-development.directory</Directory> " <Include> " " <Category>Development</Category> " </Include> </Menu>

" This submenu denition is the Development submenu. So, it identies the submenu Development (<Name>Development</Name>) in the main menu, indicates that its denition (name, icon, name translations, etc) is found in the le xfcedevelopment.directory (<Directory>xfce-development.directory</Directory>) in /usr/ share/desktop-directories. Most of the other submenu items present in XFCE menu follow this same simple menu structure. Some, however, need specic adjustments to meet XFCE designers requirements. Lets take the submenu Acessories as an example:

Fig. 4 - Accessories Submenu <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> " <Exclude> " " <Or> " " " <Filename>exo-le-manager.desktop</Filename> " " " <Filename>exo-terminal-emulator.desktop</Filename> " " " <Filename>xfce4-about.desktop</Filename> " " " <Filename>xfrun4.desktop</Filename> " " </Or> " </Exclude> </Menu>

Since youre becoming a master in XFCE menu by now, Im sure you can easily catch the meaning of this submenu. It brings two new tag elements: <Exclude></Exclude> and <Or></Or>. So, every application belonging to any of those four categories (Accesibility, Core, Legacy and Utility) are grouped together under the Accessories submenu. Conversely, every application listed between <Exclude></Exclude> is left out of the Accessories submenu. In this particular case four applications (<Filename></Filename>), not class of applications (<Category></Category>), are excluded from Accessories menu. The reason for the exclusion of these applications is that they already appear in the main menu, as you can see in Fig. 1 and in the main Layout section. Surely these applications are listed in more than one category in the Categories= line in their .desktop les. As an example, the exo-le-manager.desktop le in /usr/share/applications has the line Categories=Utility;X-XFCE;X-Xfce-Toplevel;, meaning that this specic application can appear in any menu/submenu that is categorized likewise. So, this is one way to not have the same menu item repeated in different places in the same menu, what makes the menu cumbersome. As a last example, in the full XFCE menu, lets examine Multimedia submenu:
<Menu> " <Name>Multimedia</Name> " <Directory>xfce-multimedia.directory</Directory> " <Include> " " <Category>Audio</Category> " " <Category>Video</Category> " " <Category>AudioVideo</Category> " </Include> </Menu>

In this submenu three categories of applications, Audio, Video and AudioVideo, are being grouped together under one submenu only, called Multimedia. Of course you could create individual submenus named Audio, Video and AudioVideo, provided you also created their denitions in les named, for instance, xfce-audio.directory, xfce-video.directory and xfceaudiovideo.directory.

Fig. 5 - Multimedia submenu

So guys, to customize original XFCE menu into the one that goes with Dreamlinux, I copied XFCE menu to the /home/dreamer/.cong/menus directory in the working Dreamlinux environment and made the customizations in that le. As a matter of clarication, the menu le in /home/<username>/.cong/menus has precedence over the one in /etc/xdg/menus. So, the one I modied in that directory is the one showing in Dreamlinux XFCE Desktop. If you move it out or delete it, then the original XFCE in /etc/ xdg/menus immediately replaces it. I think this is the mechanism sponsored by that <DefaultMergeDirs/> in the beginning of the menu le. Heres my a picture of my ~/.cong/ menus/xfce-applications.menu:

Fig. 6 - xfce-applications.menu in my ~/.cong/menus

So, I essentially modied XFCE menu this way: Added (for I wanted a clean menu):
<Exclude> " <Filename>xfrun4.desktop</Filename> " <Filename>exo-terminal-emulator.desktop</Filename> " <Filename>exo-lemanager.desktop</Filename> " <Filename>exo-mail-reader.desktop</Filename> " <Filename>exo-web-browser.desktop</Filename> " <Filename>xfhelp4.desktop</Filename> " <Filename>xfce4-session-logout.desktop</Filename> </Exclude>

Then I modied the main Layout section to read this:


<Layout> " <Filename>about-system.desktop</Filename> " <Filename>xfce4-about.desktop</Filename> " <Separator/> " <Menuname>Settings</Menuname> " <Separator/> <!--" <Merge type=all/> --> " <Menuname>Applications</Menuname>

" <Menuname>Games</Menuname> " <Menuname>System</Menuname> " <Menuname>Utilities</Menuname> " <Menuname>Dreamlinux</Menuname> " <Separator/> " <Filename>rce-quit.desktop</Filename> </Layout>

Added, in the Menu section (submenus):


<Menu> " <Name>Applications</Name> " <Directory>applications.directory</Directory> " <Include> " " <Category>Application</Category> " </Include> </Menu> <Menu> " <Name>Utilities</Name> " <Directory>utilities.directory</Directory> " <Include> " " <Category>Utility</Category> " </Include> </Menu> <Menu> " <Name>Dreamlinux</Name> " <Directory>dreamlinux.directory</Directory> " <Include> " " <Category>Dreamlinux</Category> " </Include> </Menu>

And created the correspondig les applications.directory, utilities.directory and dreamlinux.directory in /usr/share/desktop-directories. The resulting Dreamlinux customized XFCE menu is then:

Fig. 7 - Dreamlinux menu

Notice that I commented out (<!-- ! <Merge type=all/> -->) the merging of the other categories of submenus. Also notice that there is a submenu Games in my customized menu. However, since I didn t install any game in Dreamlinux, this submenu does not appear. As soon as I install games, as I did few minutes ago, the menu changes to this:

Fig. 7 - Games submenu

So I think everybody reading this little tutorial now is fully capable to customize his/her own XFCE menu. One nal notice though. If you decide to change your menu, I suggest you work your own copy of the pristine XFCE menu in /etc/xdg/menus. Then, besides getting rid of Dreamlinux menu (rm -f /home/<username>/.cong/menus/xfce-applications.menu), you should also delete system-menu daemon (rm -f /home/<username>/.cong/autostart/ system-menu.desktop) and erase the whole contents of /home/<username>/.local/share/ applications (rm -f /home/<username>/.local/share/applications/*). This is because I wrote a daemon that is activated in every boot and that takes care of new installs/uninstalls/ modications to /usr/share/applications, doubling it in /home/<username>/.local/share/ applications, but changing their .desktop le to make them fall into only those ve categories: Settings, Applications, Games, System, Utilities and Dreamlinux.

This is my idea of a clean, non-repetitive menu. Anyone, however, is free to modify it at will. Happy hacking. Nelson Gomes da Silveira (nelsongs) Dreamlinux Creator and Developer

Das könnte Ihnen auch gefallen