This quick guide will show you how to create gnome menus in Ubuntu that can be shared between multiple users – handy if you want to create a default menu structure that will be loaded for each user on a multiuser system. The launchers created will be installed for all users on the system.
I’ve used Ubuntu 10.10 Maverick in the following, but the guide should be working on other versions and distros (that use gnome and xdg-desktop-menu) also.
The menu consists of a tree-like structure. The structure is automatically populated when you install programs through apt or synaptic:
Since I wanted to create a sample menu with pentest tools, I’ll add the popular network scanning tool nmap to a folder structure under the main menu:
Applications |-Other |-nmap
The final menu will look like this:
To create the structure we’re going to install the application, create launcher file for it, and then add the launcher to the menu using xdg-desktop-menu.
Intalling the application
To install the tool we need, let’s issue the following command:
sudo apt-get install nmap
Creating the launcher
The easiest way to create the launcher is to create it using the Create Launcher option in Gnome. But first, let’s make sure that we are able to share the launcher with all the other users on the machine by typing the following in a terminal:
sudo mkdir /usr/local/share/applications
It is crucial that the above folder is created, the following commands will strangely not work if this directory doesn’t exist (it will instead install the nmap.desktop file to /usr/share/applications, which did not update the menu on my system).
Create a shell script to launch nmap in the Terminal
You can skip this step if you’re following this guide just to install a GUI applicaiton to the menu and share it between users.
To be able to execute nmap in a shell when we select it in the menu (BackTrack style), we must create a small helper script to prevent the terminal from shutting down the moment the nmap command terminates. . The only thing the following bash script does is exactly this:
We’ll put this script in a script catalog just below where the launcher will be stored:
cd /usr/local/share/applications sudo mkdir script sudo sh -c "echo -e '#!/bin/bash\n/usr/bin/nmap\nexec $SHELL' \ > script/nmap.sh" sudo chmod +x script/nmap.sh
Use Create Launcher to, uhm… create the launcher
To create the launcher, we simply use the Create Launcher (duh!) option in Ubuntu; right click on the desktop, and select Create Launcher:
In the following dialog, enter the name, path to the nmap shell script (or the binary/script of the application you want to launch) and a comment like below:
Check that the launcher works by double-clicking it.
Finally, to create the menu entry, enter the following command in a terminal window:
sudo xdg-desktop-menu install --novendor --mode system \ nmap.desktop
This should create a new entry in your menu under the Other category, and the link should bring up nmap in a Terminal window when clicked. This menu entry should also show up in all other user’s menus. Result: