Keys are either OPTIONAL or REQUIRED. If a key is OPTIONAL it may or may not be present in the file. However, if it isn't, the implementation of the standard should not blow up, it must provide some sane defaults.
Some keys only make sense in the context when another particular key
is also present and set to a specific value. Those keys should not be
used if the particular key is not present or not set to the specific
value. For example, the
Terminal key can only be used
when the value of the
Type key is
If a REQUIRED key is only valid in the context of another key set to a
specific value, then it has to be present only if the other key is set to
the specific value. For example, the
URL key has to be
present when and only when when the value of the
Some example keys:
Table 2. Standard Keys
This specification defines 3 types of desktop entries:
Version of the Desktop Entry Specification that the
desktop entry conforms with. Entries that confirm with this
version of the specification should use ||string||NO||1-3|
||Specific name of the application, for example "Mozilla".||localestring||YES||1-3|
||Generic name of the application, for example "Web Browser".||localestring||NO||1-3|
Tooltip for the entry, for example "View sites on the
Internet". The value should not be redundant with the values of
||Icon to display in file manager, menus, etc. If the name is an absolute path, the given file will be used. If the name is not an absolute path, the algorithm described in the Icon Theme Specification will be used to locate the icon.||localestring||NO||1-3|
A list of strings identifying the environments that should
display/not display a given desktop entry. Only one of
these keys, either ||string(s)||NO||1-3|
|Path to an executable file on disk used to determine if the program is actually installed. If the path is not an absolute path, the file is looked up in the $PATH environment variable. If the file is not present or if it is not executable, the entry may be ignored (not be used in menus, for example).||string||NO||1|
|Program to execute, possibly with arguments.||string||YES||1|
If entry is of type ||string||NO||1|
|Whether the program runs in a terminal window.||boolean||NO||1|
|The MIME type(s) supported by this application.||string(s)||NO||1|
|Categories in which the entry should be shown in a menu (for possible values see the Desktop Menu Specification).||string(s)||NO||1|
|If true, it is KNOWN that the application will send a "remove" message when started with the DESKTOP_STARTUP_ID environment variable set. If false, it is KNOWN that the application does not work with startup notification at all (does not shown any window, breaks even when using StartupWMClass, etc.). If absent, a reasonable handling is up to implementations (assuming false, using StartupWMClass, etc.). (See the Startup Notification Protocol Specification for more details).||boolean||NO||1|
|If specified, it is known that the application will map at least one window with the given string as its WM class or WM name hint (see the Startup Notification Protocol Specification for more details).||string||NO||1|
|If entry is Link type, the URL to access.||string||YES||2|
Exec key must contain a command line.
A command line consists of an executable program optionally followed
by one or more arguments.
The executable program can either be specified with its full path or
with the name of the executable only. If no full path is provided the
executable is looked up in the $PATH environment variable used by the
The name or path of the executable program may not contain the equal
sign ("="). Arguments are separated by a space.
Arguments may be quoted in whole. If an argument contains a reserved character the argument must be quoted. The rules for quoting of arguments is also applicable to the executable name or path of the executable program as provided.
Quoting must be done by enclosing the argument between double quotes and escaping the double quote character, backtick character ("`"), dollar sign ("$") and backslash character ("\") by preceding it with an additional backslash character. Implementations must undo quoting before expanding field codes and before passing the argument to the executable program. Reserved characters are space (" "), tab, newline, double quote, single quote ("'"), backslash character ("\"), greater-than sign (">"), less-than sign ("<"), tilde ("~"), vertical bar ("|"), ampersand ("&"), semicolon (";"), dollar sign ("$"), asterisk ("*"), question mark ("?"), hash mark ("#"), parenthesis ("(") and (")") and backtick character ("`").
Note that the general escape rule for values of type string states that the backslash character can be escaped as ("\\") as well and that this escape rule is applied before the quoting rule. As such, to unambiguously represent a literal backslash character in a quoted argument in a desktop entry file requires the use of four successive backslash characters ("\\\\"). Likewise, a literal dollar sign in a quoted argument in a desktop entry file is unambiguously represented with ("\\$").
A number of special field codes have been defined which will be
expanded by the file manager or program launcher when encountered
in the command line.
Field codes consist of the percentage character ("%") followed by
an alpha character. Literal percentage characters must be escaped
Deprecated field codes should be removed from the command line and
Field codes are expanded only once, the string that is used to
replace the field code should not be checked for field codes itself.
Command lines that contain a field code that is not listed in this specification are invalid and must not be processed, in particular implementations may not introduce support for field codes not listed in this specification. Extensions, if any, should be introduced by means of a new key.
Implementations must take care not to expand field codes into multiple arguments unless explicitly instructed by this specification. This means that name fields, filenames and other replacements that can contain spaces must be passed as a single argument to the executable program after expansion.
Exec key is defined to have a value
of the type string, which is limited to ASCII characters, field code
expansion may introduce non-ASCII characters in arguments.
Implementations must take care that all characters in arguments
passed to the executable program are properly encoded according to
the applicable locale setting.
Recognized field codes are as follows:
A single file name, even if multiple files are selected. The system
reading the desktop entry should recognize that the program in
question cannot handle multiple file arguments, and it should
should probably spawn and execute multiple copies of a program
for each selected file if the program is not able to handle
additional file arguments. If files are not on the local file system
(i.e. are on HTTP or FTP locations), the files will be copied to the local
file system and |
|A list of files. Use for apps that can open several local files at once. Each file is passed as a separate argument to the executable program.|
|A single URL. Local files may either be passed as file: URLs or as file path.|
|A list of URLs. Each URL is passed as a separate argument to the executable program. Local files may either be passed as file: URLs or as file path.|
The translated name of the application as listed in
the appropriate |
|The location of the desktop file as either a URI (if for example gotten from the vfolder system) or a local filename or empty if no location is known.|
A command line may contain at most one %f, %u, %F or %U field code. If the application should not open any file the %f, %u, %F and %U field codes must be removed from the command line and ignored.
Field codes must not be used inside a quoted argument, the result of field code expansion inside a quoted argument is undefined. The %F and %U field codes may only be used as an argument on their own.
MimeType key is used to indicate the MIME
Types that an application knows how to handle. It is expected that
for some applications this list could become long. An application
is expected to be able to reasonably open files of these types
using the command listed in the
There should be no priority for MIME Types in this field, or any
form of priority in the desktop file. Priority for applications
is handled external to the
As this standard is quite old there are some deprecated items that may or may not be used by several implementations.
Type=MimeType is deprecated as there is a
new standard for this now, see the Shared
MIME-info Database specification for more
information. In consequence the Keys
Patterns (various file name extensions
associated with the MIME type) and
DefaultApp (the default application
associated with this MIME type) are also deprecated.
.kdelnk instead of
.desktop as the file extension is
[KDE Desktop Entry] instead of
[Desktop Entry] as header is deprecated.
Encoding key is deprecated. It was used to
specify whether keys of type
encoded in UTF-8 or in the specified locale. Possible values are
Appendix D, The
Legacy-Mixed Encoding (Deprecated) for more details.
Exec field codes:
%m (the mini-icon associated with the
desktop entry, this should be expanded as two arguments,
--miniicon and the content of the
MiniIcon key, it can also be ignored by
expanding it to no arguments), %v (the device as listed
Dev key in the desktop file),
%d (the directory of a file), %D (the directories of
files), %n (the base name of a file) and %N (the base names
MiniIcon (small icon for
TerminalOptions (if the
program runs in a terminal, any options that should be
passed to the terminal emulator before actually executing
SwallowExec keys are deprecated.
SwallowTitle key is of type
localestring and specifies the title of the window
if is swallowed onto the panel. The
key is of type
string and specifies the
program to exec if swallowed app is clicked.
SortOrder key is deprecated. It is of type
string(s) and may be used to specify the order in
which to display files. The Desktop
Menu Specification defines another mechanism for defining the
order of menu items.
FilePattern key is deprecated.
The value is a list of regular
expressions to match against for a file manager to determine if this
entry's icon should be displayed. Usually simply the name of the main
executable and friends.
Historically some booleans have been represented by the numeric
this version of the standard they are now to be represented as a
boolean string. However, if an implementation is reading a pre-1.0
desktop entry, it should interpret
Historically lists have been comma separated. This is inconsistent with other lists which are separated by a semicolon. When reading a pre-1.0 desktop entry, comma separated lists should continue to be supported.