Add menu item on Debian

Create Menu Item

The menu item are stored in two places:

  1. /usr/share/applications  directory which is accessible by every one.
  2. ~/.local/share/application s directory which is accessible to a single user.

The menu item is stored as a .desktop file. The file should be UTF-8 coded and resemble the following example which adds the Google chrome item to the application menu.

[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Icon[en_US]=google-chrome
Name[en_US]=Google Chrome
Exec=/opt/google/chrome/google-chrome
Name=Google Chrome
Icon=google-chrome

 Line by line explanation

Line Description
[Desktop Entry] The first line of every desktop file and the section header to identify the block of key value pairs associated with the desktop. Necessary for the desktop to recognize the file correctly.
Type=Application Tells the desktop that this desktop file pertains to an application. Other valid values for this key are Link and Directory.
Encoding=UTF-8 Describes the encoding of the entries in this desktop file.
Name=Sample Application Name Names of your application for the main menu and any launchers.
Comment=A sample application Describes the application. Used as a tooltip.
Exec=application The command that starts this application from a shell. It can have arguments.
Icon=application.png The icon name associated with this application.
Terminal=false Describes whether application should run in a terminal.

If your application can take command line arguments, you can signify that by using the fields as shown below:

Add… Accepts…
%f a single filename.
%F multiple filenames.
%u a single URL.
%U multiple URLs.
%d a single directory. Used in conjunction with %f to locate a file.
%D multiple directories. Used in conjunction with %F to locate files.
%n a single filename without a path.
%N multiple filenames without paths.
%k a URI or local filename of the location of the desktop file.
%v the name of the Device entry.

Official Specification

Desktop Entry Specification:
http://standards.freedesktop.org/desktop-entry-spec/latest/index.html