Customising the Oracle XE Menu in XFCE – why it’s better to be vegetarian

Roberto Goldbrick. The name of the central character in a biting satire about a Premiership footballer ? Actually, it’s the name of the horse I drew out in the Office Grand National Sweep Stake.

“Oh well”, said Deb as the winner crossed the line with Roberto nowhere to be seen, “by next week it’ll be a value frozen lasagne”.
That’s the thing about vegetarians, they do like to assert their moral superiority at times. It can be quite difficult to find a suitable riposte. After all, you feel a bit of a twit accusing someone of vegicide.

In order to overcome my disappointment, I’ve taken refuge in Mint 14 XFCE running on my netbook.

Using the steps here and here I’ve managed to install Oracle 11gXE without any problems….apart from the fact that the Menu items now appear on the Others menu.
Being a lightweight desktop, XFCE doesn’t provide a default GUI to enable menu editing, so I’ve had to do a bit of investigation…

XFCE Menu files

In order to get my Oracle Menu, together with the correct entries, there are three types of file I need to deal with.

desktop files

Each menu item has it’s own .desktop file. These can be found in /usr/share/applications.
To see all the files that were created as part of the XE installation:

cd /usr/share/applications
ls oracle*.desktop

You should see…

oraclexe-backup.desktop             oraclexe-registerforonlineforum.desktop
oraclexe-getstarted.desktop         oraclexe-restore.desktop
oraclexe-gettingstarted.desktop     oraclexe-runsql.desktop
oraclexe-gotoonlineforum.desktop    oraclexe-startdb.desktop
oraclexe-readdocumentation.desktop  oraclexe-stopdb.desktop

If we have a look at the contents of the oraclexe-startdb.desktop file :

[Desktop Entry]
Exec=/u01/app/oracle/product/11.2.0/xe/config/scripts/startdb.sh
Terminal=false
MultipleArgs=true
Type=Application
Categories=Applications;
Icon=oraclexe-startdatabase.png
MimeType=Application/database
Encoding=UTF-8
Name=Start Database
Name[pt_BR]=Iniciar Banco de Dados
Name[ja]=データベースの起動
Name[zh_CN]=启动数据库

Most of that is fairly straight forward. The file details the script that should be executed, whether a Terminal should be opened, the icon to display on the menu etc.
The menu it needs to appear on? That’s a different story.

Directory Files

These files act as containers for the .desktop files within the Menu structure. They should all be in /usr/share/desktop-directories.
The Oracle menu however, has been created in /usr/share/desktop-menu-files.
Before we start moving it around, it’s probably worth having a look at it’s contents (the filename is oraclexe-11g.directory):

[Desktop Entry]
Icon=oraclexe-11g.png
Type=Directory
Encoding=UTF-8

Name=Oracle Database 11g Express Edition
Name[pt_BR]=Oracle Database 11g Express Edition
Name[ja]=Oracle Database 11g Express Edition
Name[zh_CN]=Oracle Database 11g Express Edition

On it’s own, it doesn’t really move the story on much, save for the fact that it is defined as being of type Directory.

Finally, however, we get to the heart of the menu system.

The Menu file

The file /usr/share/xfcemint/xfce-applications.menu is where all of the magic happens. This is an XML file which controls the contents of the Menu itself. Let’s take a look at the definition for the System menu :

    <Menu>
        <Name>System</Name>
        <Directory>xfce-system.directory</Directory>
        <Include>
            <Or>
                <Category>Emulator</Category>
                <Category>System</Category>
            </Or>
        </Include>
        <Exclude>
            <Or>
                <Filename>Thunar.desktop</Filename>
                <Filename>xfce4-session-logout.desktop</Filename>
            </Or>
        </Exclude>
    </Menu>

We can see that the entry references the appropriate .directory file.
We can also see that the menu can include either categories of .desktop files or specifically named files.
OK, so in this case, the named files are specifically excluded from the menu, but the principle should be sound.

Getting the Oracle Menu

There would appear to be two ways to do this. The first is to specify the files to include on the menu explicitly. The second is to edit the .desktop files to specify a category which we can then include in the Oracle menu by means of the tags in the .desktop and .menu files.
Either way, the first thing we need to do is to copy the oracle .directory file to the correct location :

sudo cp /usr/share/desktop-menu-files/oraclexe-11g.directory /usr/share/desktop-directories/.

Option 1 – specify the files

We now need to add an entry into the xfce-applications.menu. OK, strictly speaking, we now need to backup the xfce-applications.menu file, just in case our XML skills aren’t quite as good as we thought they were :

sudo cp /usr/share/xfcemint/xfce-applications.menu xfce-applications.bak

Now, let’s add in the Oracle menu :

    <Menu>
        <Name>Oracle Database 11g Express Edition</Name>
        <Directory>oraclexe-11g.directory</Directory>
        <Include>
           <Filename>oraclexe-startdb.desktop</Filename>
           <Filename>oraclexe-stopdb.desktop</Filename>
           <Filename>oraclexe-runsql.desktop</Filename>
           <Filename>oraclexe-backup.desktop</Filename>
           <Filename>oraclexe-restore.desktop</Filename>
           <Filename>oraclexe-gettingstarted.desktop</Filename>
           <Filename>oraclexe-readdocumentation.desktop</Filename>
           <Filename>oraclexe-registerforonlineforum.desktop</Filename>
           <Filename>oraclexe-gotoonlineforum.desktop</Filename>
           <Filename>oraclexe-getstarted.desktop</Filename>
        </Include>

    </Menu>

NOTE – I added this above the entry for the Others menu, which seems to be a catch-all for anything that doesn’t fit in any of the menus previously defined in the file.

Save the change, now go back to the desktop and fire up the Menu…

ora_menu

Option 2 – Use a category

Well, that seemed to work quite well. However, if we wanted to add another item to the menu, we would need to go and edit xfce-applications.menu all over again.
A more dynamic approach would be to use a Category. This would mean that any new .desktop files of the appropriate category would automatically be included.
To do this, we’ll need to add the category to both our existing desktop files and to the menu definition in xfce-applications.menu.
Let’s call the category XE.

First of all, we need to change the appropriate desktop files. Time for a small script…save_category.sh

#!/bin/sh
#
# Script to add a category to all of the oracle .desktop files
#
for dtfile in $(ls /usr/share/applications/oraclexe-*.desktop)
do
	cp $dtfile $dtfile.bak
	sed -i 's/Categories=Applications;/Categories=Applications;XE/' $dtfile
done
exit 0

We need to run this using sudo as we don’t have permissions on these files…

sudo sh change_category.sh

If we have a look at the .desktop files now, we should see that the category tag has been changed and the category XE added :

[Desktop Entry]
Exec=/u01/app/oracle/product/11.2.0/xe/config/scripts/startdb.sh
Terminal=false
MultipleArgs=true
Type=Application
Categories=Applications;XE
Icon=oraclexe-startdatabase.png
MimeType=Application/database
Encoding=UTF-8
Name=Start Database
Name[pt_BR]=Iniciar Banco de Dados
Name[ja]=データベースの起動
Name[zh_CN]=启动数据库

Now we need to go back to the menu and replace the hard-coded filenames with the new category :

   <Menu>
        <Name>Oracle Database 11g Express Edition</Name>
        <Directory>oraclexe-11g.directory</Directory>
        <Include>
           <Category>XE</Category>
        </Include>

    </Menu>

Now, when we hit the big shiny menu button…you get exactly the same result.
If you want to do more than just get your Oracle XE stuff onto the menu, there’s a really useful howto on the XFCE wiki.

As for me, domestic drudgery calls. Looks like I’m going to have to ruthlessly skin some defenceless potatoes.

Author: mikesmithers

Back in 1993, I discovered that I could get paid money for doing fun stuff with computers. Over the years, I've specialised in Oracle Databases as a developer, a DBA and sometimes, an architect. It's my evil alter-ego - The Antikyte - who writes a blog about my various technical adventures. Yes, that is his Death Star parked in the Disabled Bay. I currently live in the South-West of England with Deb, my long-suffering wife.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.