Desktop entries are defined by the freedesktop.org Desktop Entry Specification, version 1.5 (published 27 April 2020); section numbers below refer to it.
Syntax
- The file is UTF-8 text, lines separated by line feeds; case is significant
everywhere (section 3). Lines starting
#and blank lines are comments, which writers should keep. - A group header is
[name]; group names may use any ASCII character except[,]and control characters, and no two groups may share a name. The[Desktop Entry]group is required, and only comments may come before it. - Entries are
Key=Value; spaces before and after the=are ignored. Keys are made ofA–Z,a–z,0–9and-, and may appear only once in a group. Programs that rewrite the file must keep keys they do not know.
| Value type | Form (section 4) |
|---|---|
| string | Any ASCII characters except control characters. |
| localestring | UTF-8 text shown to the user, which may have translations. |
| iconstring | An icon’s name, found with the Icon Theme Specification, or an absolute path; UTF-8, not shown to the user. |
| boolean | true or false. |
| numeric | A floating-point number as scanf’s %f reads it in the C locale. |
In string, localestring and iconstring values \s, \n,
\t, \r and \\ stand for space, newline, tab,
carriage return and backslash. Keys that take several values separate them with
; (a literal semicolon is \;); the list may end with a
;, and must if its last value is empty.
Translations
A localestring or iconstring key may be followed by a locale in brackets:
Name[fr]=Éditeur de texte; the key must then also be present without
one (section 5). The locale is lang_COUNTRY.ENCODING@MODIFIER, any part
but lang optional, and is matched against LC_MESSAGES with
the encoding ignored. For a user in sr_YU@Latn, a program looks for
Name[sr_YU@Latn], then Name[sr_YU], then
Name[sr@Latn], then Name[sr], then Name. A
locale without a country or modifier never matches keys that have one.
Keys
Applies to: A Application, L Link, D Directory.
| Key | Type | Required | For | Meaning |
|---|---|---|---|---|
Type | string | yes | all | Application, Link or Directory; other values are ignored. |
Version | string | no | all | Version of the specification the file follows, such as 1.5. |
Name | localestring | yes | A L D | The name shown, such as Firefox. |
GenericName | localestring | no | A L D | What it is, such as Web Browser. |
NoDisplay | boolean | no | A L D | Keep it out of menus while still usable, for example for file associations. |
Comment | localestring | no | A L D | A tooltip. |
Icon | iconstring | no | A L D | The icon. |
Hidden | boolean | no | A L D | Treat the entry as deleted (used to hide a system-wide entry for one user). |
OnlyShowIn, NotShowIn | strings | no | A L D | Desktop environments (names as in $XDG_CURRENT_DESKTOP) that should or should not show it. |
DBusActivatable | boolean | no | all | Start the application over D-Bus; Exec is then ignored by launchers that support it. |
TryExec | string | no | A | A program to check for; if missing, the entry may be hidden. |
Exec | string | yes, unless D-Bus activatable | A | The command line; see Exec. |
Path | string | no | A | The working directory. |
Terminal | boolean | no | A | Run it in a terminal window. |
Actions | strings | no | A | IDs of additional actions. |
MimeType | strings | no | A | Media types the application can open. |
Categories | strings | no | A | Menu categories (from the Desktop Menu Specification), such as Utility;TextEditor;. |
Implements | strings | no | all | D-Bus interfaces the application implements. |
Keywords | localestrings | no | A | Extra words to find it by in searches. |
StartupNotify | boolean | no | A | The application signals when it has started, so the launcher can show progress. |
StartupWMClass | string | no | A | The window class it will map, for startup notification. |
URL | string | yes | L | The address a Link entry opens. |
PrefersNonDefaultGPU | boolean | no | A | Run it on the discrete graphics card if there is one. |
SingleMainWindow | boolean | no | A | It has one main window; do not offer to open another. |
Keys of one’s own start with X- and a product name, such as
X-NewDesktop-Foo; or they go in a group of their own named like
[X-PRODUCT GROUPNAME], where any key names may be used (section
12).
Exec
The command and its arguments, separated by spaces. Field codes are replaced when the program is started:
| Code | Replaced by |
|---|---|
%f | One file path; with several files, the program is started once per file. Remote files are copied locally first. |
%F | A list of files, each a separate argument. |
%u | One URL (a local file may be a path or a file: URL). |
%U | A list of URLs. |
%i | --icon and the Icon value, as two arguments; nothing if there is no icon. |
%c | The translated Name. |
%k | The location of the desktop file. |
%% | A percent sign. |
%d, %D, %n, %N, %v, %m | Deprecated: removed and ignored. |
- At most one of
%f,%F,%u,%U;%F,%Uand%imust be whole arguments; field codes must not be inside quotes. Any other%code makes the line invalid. - An argument with a space or one of
" ' \ > < ~ | & ; $ * ? # ( )or a backtick is put in double quotes, inside which",`,$and\are escaped with a backslash. Because the string escapes apply first, a backslash in a quoted argument is written as four backslashes in the file.
Additional actions
An Application entry may list action IDs, written like key names, in
Actions; each has a group [Desktop Action id]
(section 11). Its Name (localestring) is required, or the action is
ignored; Icon is optional; Exec is required unless the
main group sets DBusActivatable=true. A group for an ID not listed in
Actions is ignored. Launchers should offer the actions within the
application’s context, for example as a submenu (“quicklists” or
“jumplists”).
[Desktop Entry]
Type=Application
Name=Browser
Exec=browser %u
Actions=new-window;
[Desktop Action new-window]
Name=New Window
Exec=browser --new-window