xubuntu - manually modifying the xfce Applications menu

Open baby

xubuntu - manually modifying the xfce Applications menu

Postby intodis » 26 May 2009, 04:14

I am writing this at 3:30am in the morning so will make it short and sweet, some details may be missed but you should get the idea ...

First there are 4 folders you need to be aware of (plus another one I will mention later), these contain the menus .desktop (application launcher) configuration files and hold the .directory (menu sub-nodes) configuration files.

~/.local/share/applications
~/.local/share/desktop-directories
/usr/share/applications
/usr/share/desktop-directories

~ =/home/me (your home folder)

Code: Select all
cd /usr/share/applications
mousepad firefox.desktop

You will see the definition for the launcher:
Code: Select all
[Desktop Entry]
Version=1.0
Name=Firefox Web Browser
Name[ca]=Navegador web Firefox
...
Name[sv]=Webbläsaren Firefox
Comment=Browse the World Wide Web
Comment[ca]=Navegueu per el web
...
Comment[sv]=Surfa på webben
GenericName=Web Browser
...
GenericName[sv]=Webbläsare
Exec=firefox %u
Terminal=false
X-MultipleArgs=false
Type=Application
Icon=firefox-3.0
Categories=Application;Network;
MimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/vnd.mozilla.xul+xml;application/rss+xml;application/rdf+xml;image/gif;image/jpeg;image/png;
StartupWMClass=Firefox
StartupNotify=true

Of interest to us is the Categories=Application;Network; line this tell us where in the menu the launcher will be placed.

Code: Select all
cd /usr/share/desktop-directories
mousepad xfce-network.directory

Will show the definition for the Network node:
Code: Select all
[Desktop Entry]
Version=1.0
Encoding=UTF-8
Type=Directory
Icon=applications-internet
Name=Network
Name[ar]=شبكة
...
Name[zh_TW]=網路
Comment=Network applications and utilities
Comment[ar]=تطبيقات وأدوات الشبكة
...
Comment[zh_CN]=网络应用程序和实用工具

There isn't much interesting in this file, but I thought I would show you it to tie in the next part.

Now we want to find the XFCE Applications menu definition file this is in another location (for me it was)
Code: Select all
mousepad /etc/xdg/xubuntu/menus/xfce-applications.menu

The part of this that relates to the XFCE menus Applications/Network is:
Code: Select all
<Menu>
    <Name>Network</Name>
    <Directory>xfce-network.directory</Directory>
    <Include>
        <Category>Network</Category>
    </Include>
</Menu>

The <Menu> tag means create a sub-menu node in the current menu, which just happens to be the XFCE menu (Applications).
Name doesn't actually do much as it is overridden by the Name definition in the Directory xfce-network.directory definition file, this I showed you above. That definition file also sets the icon ...
The <include> tag is where it gets interesting, the Category element defines what launchers will be included in this sub-menu and this ties back to the Categories line in the .desktop launcher definition files. In the firefox.desktop we looked at above it has Categories=Application;Network; so I hope this show why firefox is under the Network sub-menu.

<Menu> XML elements can be embedded in other <Menu> elements this will give cascading sub-menus.

Note if installing Wine. All the launchers will be added to the Other sub-menu. This is because in /etc/xdg/xubuntu/menus/xfce-applications.menu the Wine, Wine-Programs and Wine-Programs-Accessories <Menu> elements are not created by default in xubuntu even though the .desktop and .directory files are created.

By added the following after taking a backup of you original /etc/xdg/xubuntu/menus/xfce-applications.menu file, a new Wine sub-menu will be displayed on the Applications menu and the Wine launchers will be removed from the Other sub-menu and shown in the Wine sub-menus.
Code: Select all
<Menu>
    <Name>Wine</Name>
    <Directory>wine.directory</Directory>
    <Include>
        <Category>Wine</Category>
    </Include>

    <Menu>
        <Name>Programs</Name>
        <Directory>wine-Programs.directory</Directory>
        <Include>
            <Category>Wine-Programs</Category>
        </Include>

        <Menu>
       <Name>Accessories</Name>
       <Directory>wine-Programs-Accessories.directory</Directory>
       <Include>
           <Category>Wine-Programs-Accessories</Category>
       </Include>
    </Menu>

    </Menu>

</Menu>


You can define your own sub-menus. Especially useful with wine programs. Then just create .directory file for the sub-menu and then create .desktop, making sure to match up the categories.
intodis
Site Admin
 
Posts: 204
Joined: 30 Mar 2006, 20:57

Return to Ubuntu/Linux

Who is online

Users browsing this forum: No registered users and 1 guest

cron