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 file /home/ <username/.config/menus/xfce-applications.menu elsewhere. The same applies to the directory /home/<username>/.local/share/applications. At the end you can move back those file and directory to their original places. XFCE menu follows freedesktop.org specifications, as most major Desktop environments like Gnome and KDE do. XFCE’s menu is devided in sections and its organization is kept in an XML file 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 XFCE’s menu root is: <Menu> </Menu> The first element, that identifies 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>/.config/ menus. So, our menu file description grows to this: <Menu> <Name>Xfce</Name> <DefaultAppDirs/> <DefaultDirectoryDirs/> <DefaultMergeDirs/> </Menu>

Customize XFCE (THE EASY WAY)

Embed Size (px)

DESCRIPTION

Customize and design your own main menu inside the XFCE Desktop Environment in the easiest way!

Citation preview

Page 1: Customize XFCE (THE EASY WAY)

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 file /home/<username/.config/menus/xfce-applications.menu elsewhere. The same applies to the directory /home/<username>/.local/share/applications. At the end you can move back those file and directory to their original places.

XFCE menu follows freedesktop.org specifications, as most major Desktop environments like Gnome and KDE do.

XFCE’s menu is devided in sections and its organization is kept in an XML file 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 XFCE’s menu root is:

<Menu></Menu>

The first element, that identifies 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>/.config/menus. So, our menu file description grows to this:

<Menu>! <Name>Xfce</Name>

! <DefaultAppDirs/>! <DefaultDirectoryDirs/>! <DefaultMergeDirs/>!</Menu>

Page 2: Customize XFCE (THE EASY WAY)

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-Xfce-Toplevel. 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-file-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 XFCE’s menu is Run program application, followed by a separator line. Notice that there are two applications here, described in their respective .desktop files (freedesktop.org specifications): xfrun4.desktop and xfce4-run.desktop. If there were these two files in /usr/share/applications, both applications would show there at the top. As I aforementioned these are specific XFCE applications, categorized by the value X-Xfce-

Page 3: Customize XFCE (THE EASY WAY)

Toplevel in their Categories= class, in their respective .desktop files 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 first is surrounded by two <Separator/> elements and describes the first instance of submenus in the menu (see figure 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 files or files grouped by a submenu. That's why you have all those submenus Accessories, Development, Graphics, Internet, Multimedia, Office, Other and System, plus About This System, which is a regular Dreamlinux specific application, present in /usr/share/applications. Since it's categorized as a X-Xfce-Toplevel application

Page 4: Customize XFCE (THE EASY WAY)

(although it’s a Dreamlinux specific 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 find 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 first, surrounded by separator lines and described by the enclosing <Menuname></Menuname> tag in the Layout section. It’s defined 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>

Page 5: Customize XFCE (THE EASY WAY)

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

Page 6: Customize XFCE (THE EASY WAY)

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 first 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 specific file (xfce-settings.directory) resides in /usr/share/desktop-directories. Have a look in it to have an idea.

Proceeding, notice that, after being identified 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 definition file (.desktop) in /usr/share/applications will show under the Settings submenu.

Specifically to the Settings submenu, notice that it layouts itself to have the xfce-settings-manager application (<Filename>xfce-settings-manager.desktop</Filename>) on its top and a submenu comprised of Screensavers specific applications. If there are screensaver applications, they shall appear under a screensavers submenu that is named and featured at a .directory file in /usr/share/desktop-directories. If there’s no screensavers aplications, then this submenu does not appear, although defined.

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 definition is the Development submenu. So, it identifies the submenu Development (<Name>Development</Name>) in the main menu, indicates that its definition (name, icon, name translations, etc) is found in the file xfce-development.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 specific adjustments to meet XFCE designers requirements. Let’s take the submenu Acessories as an example:

Page 7: Customize XFCE (THE EASY WAY)

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-file-manager.desktop</Filename>" " " <Filename>exo-terminal-emulator.desktop</Filename>" " " <Filename>xfce4-about.desktop</Filename>" " " <Filename>xfrun4.desktop</Filename>" " </Or>" </Exclude></Menu>

Page 8: Customize XFCE (THE EASY WAY)

Since you’re becoming a master in XFCE menu by now, I’m 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 files. As an example, the exo-file-manager.desktop file in /usr/share/applications has the line Categories=Utility;X-XFCE;X-Xfce-Toplevel;, meaning that this specific 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, let’s 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 definitions in files named, for instance, xfce-audio.directory, xfce-video.directory and xfce-audiovideo.directory.

Page 9: Customize XFCE (THE EASY WAY)

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/.config/menus directory in the working Dreamlinux environment and made the customizations in that file. As a matter of clarification, the menu file in /home/<username>/.config/menus has precedence over the one in /etc/xdg/menus. So, the one I modified 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 file. Here’s my a picture of my ~/.config/menus/xfce-applications.menu:

Page 10: Customize XFCE (THE EASY WAY)

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

So, I essentially modified XFCE menu this way:

Added (for I wanted a clean menu):<Exclude>" <Filename>xfrun4.desktop</Filename>" <Filename>exo-terminal-emulator.desktop</Filename>" <Filename>exo-filemanager.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 modified 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>

Page 11: Customize XFCE (THE EASY WAY)

" <Menuname>Games</Menuname>" <Menuname>System</Menuname>" <Menuname>Utilities</Menuname>" <Menuname>Dreamlinux</Menuname>" <Separator/>" <Filename>firce-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 files applications.directory, utilities.directory and dreamlinux.directory in /usr/share/desktop-directories.

The resulting Dreamlinux customized XFCE menu is then:

Fig. 7 - Dreamlinux menu

Page 12: Customize XFCE (THE EASY WAY)

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 final 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>/.config/menus/xfce-applications.menu), you should also delete system-menu daemon (rm -f /home/<username>/.config/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/modifications to /usr/share/applications, doubling it in /home/<username>/.local/share/applications, but changing their .desktop file to make them fall into only those five categories: Settings, Applications, Games, System, Utilities and Dreamlinux.

Page 13: Customize XFCE (THE EASY WAY)

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