A .desktop file is a launcher. When run, it executes a command, which usually launches an application. Use this tag if you are asking a question about using a .desktop file or about the .desktop file format in general.
A .desktop file (MIME type: application/x-desktop) is a text file (editable in virtually any text editor like emacs, gedit or vim, for example) that is used to create program launchers on systems running the X Windowing System. More formally, a .desktop file is a configuration file standardized in the Desktop Entry Specification. It is usually used as an application launcher, which may appear in a menu, on a desktop, or in search results. Application launchers that appear on the Unity left sidebar all appear in one of two possible places: /usr/share/applications or ~/.local/share/applications.
Structure
It has the following basic structure:
[Desktop Entry]
Key1=Value1
Key2=Value2
Key3=Value3
. . . (and so on)
Where Key(i) (where i=1,2,3,...,n) and Value(i) can be one of a fixed set described here.
Common keys
CategoriesThis is an optional field that refers to what type of application the launcher is. Like an educational application (e.g., avogadro, openbabel, octave, etc.) would have the category
Education. Each category is separated by a semicolon (;).CommentThis is an optional field that provides a short description of the program the desktop file launches.
ExecThis is what the launcher runs through bash. For example,
Exec=scilabwould run scilab, if it is installed. This field is mandatory ifType=Application.GenericNameThis is a more generic name (like a group name for the set of applications to which the application belongs) for the application. For example, gedit may have
GenericName=Text editor, likewise emacs might have the sameGenericNamevalue, that is,Text editor. This key is optional.IconThis is the icon given to the launcher. Desktop configuration files by default take their icons from
/usr/share/pixmaps/,/usr/share/icons/and~/.local/share/icons/, although if you specify the full path of the icon you want you may use icon files outside these directories. These icons can be in a range of different file formats including, but not limited to,.gif,.jpg,.png,.svgand.xpm. This field is optional; if it is omitted an icon like that below will be used in its place.
KeywordsThis is an optional field that serves as metadata for the desktop entry.
MimeTypeThis is an optional field that is used to determine which files it will appear in the "Open With" context-menu for. For example, if
MimeType=text/plainthen if this desktop file is saved in the/usr/share/applicationsor~/.local/share/applicationsdirectories it will appear in the open with menu for all plain text files (e.g., those with the file extension.txt).NameThis is the name with which the icon is displayed (e.g., if
Name=geditthen your launcher will be called gedit). This field can be specified for different languages too, for example, you may have one lineName[en_US]=GNOME Colorsthat is the Name that appears for the launcher when you are using US English and another lineName[en_AU]=GNOME Coloursfor if you are using Australian English. This key is mandatory.TerminalThis field can be either
YesorNoand refers to whether or not the program is to be run in the terminal. It is optional and its default value isNo.TypeThis is a mandatory field that can only take on three values
Application,LinkorDirectory. It refers to the nature of the launcher, that is, what it does, like whether it serves as a link to a file or folder, or whether it runs an application.