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
Categories
This 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 (;
).Comment
This is an optional field that provides a short description of the program the desktop file launches.
Exec
This is what the launcher runs through bash. For example,
Exec=scilab
would run scilab, if it is installed. This field is mandatory ifType=Application
.GenericName
This 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 sameGenericName
value, that is,Text editor
. This key is optional.Icon
This 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
,.svg
and.xpm
. This field is optional; if it is omitted an icon like that below will be used in its place.Keywords
This is an optional field that serves as metadata for the desktop entry.
MimeType
This 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/plain
then if this desktop file is saved in the/usr/share/applications
or~/.local/share/applications
directories it will appear in the open with menu for all plain text files (e.g., those with the file extension.txt
).Name
This is the name with which the icon is displayed (e.g., if
Name=gedit
then 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 Colors
that is the Name that appears for the launcher when you are using US English and another lineName[en_AU]=GNOME Colours
for if you are using Australian English. This key is mandatory.Terminal
This field can be either
Yes
orNo
and refers to whether or not the program is to be run in the terminal. It is optional and its default value isNo
.Type
This is a mandatory field that can only take on three values
Application
,Link
orDirectory
. 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.