Blog RSS

The thought-stream of Tom Medhurst

Archive

Mar
7th
Sat
permalink

How to programmatically create GNOME start menu items in Ubuntu 8.10 Intrepid (using .desktop config files)

This will probably work with operating systems (and desktop managers, such as KDE) other than Ubunutu & GNOME as the schema is a standard one (http://www.freedesktop.org/). However directories may vary slightly; so I can only confirm this works with Ubuntu 8.10…

There are .menu files which create the menu structure. Your current logged-in user’s local .menu files can be found at: ~/.config/menus/
There are other .menu files dotted around.. you can find these using locate .menu

However the .menu files do not contain menu items (I am assuming you are happy to place your shortcut in one of the pre-defined categories available to the GNOME & KDE menus); shortcuts to programs are in files with the .desktop extension.

In Ubuntu, the easiest way to add a new menu item is to add a new .desktop file into: /usr/share/applications/

This file should contain name/value pairs separated by the equals sign and new-lines. The schema can be found here. Below is an example .desktop file:

[Desktop Entry]
Version=1.0
Name=Application Name
Name[es]=Application Name in Spanish
Comment=Description of Application
Exec=COMMAND_AND_ARGS_HERE
Terminal=false
Type=Application
Icon=applications-office
Categories=Application;System;

I have found little or no documentation regarding how to do this on Google (plus the free-desktop-org web site is not the easiest to follow!); so I hope my findings has helped a few people out! :)

Comments (View)
blog comments powered by Disqus