Introduction
A .desktop file tells a Linux desktop how to show and start an
application: its name in each language, its icon, the command to run, the file types it
opens and where it belongs in the menu. Every application in the GNOME, KDE Plasma, Xfce
and other menus has one, usually in /usr/share/applications or
~/.local/share/applications. Files in ~/.config/autostart
start programs at sign-in.
The format is the Desktop Entry Specification from freedesktop.org, shared by the free desktops so that one file works in all of them. A desktop entry can also be a link to a web address or describe a folder.
Structure
A desktop entry is UTF-8 text in the style of an INI file (see
syntax and keys). It starts with the group
[Desktop Entry], followed by Key=Value lines. Type
is Application, Link or Directory.
Name is required, and can be translated with keys such as
Name[fr]. Exec gives the command line, where codes such as
%f and %U stand for the files or addresses being opened.
Categories and MimeType are lists separated by semicolons.
Further groups, such as [Desktop Action new-window], add extra actions to
the launcher’s menu. Lines starting with # are comments.
[Desktop Entry]
Type=Application
Name=Text Editor
Exec=gnome-text-editor %U
Icon=org.gnome.TextEditor
Categories=Utility;TextEditor;
MimeType=text/plain;
Not described
These pages follow the freedesktop.org Desktop Entry Specification 1.5. The explorer has no desktop entry viewer, so a dropped file shows as bytes.
Known, not yet covered
- Reference: the list of registered menu categories belongs to a separate specification, the Desktop Menu Specification, and is not reproduced.
- Viewer: there is no plugin: groups, keys, locale suffixes and actions are not read.
Links
Software
- GNOME – desktop that reads desktop entries for its menus and launcher (Linux)
- KDE Plasma – desktop whose menu editor also writes them (Linux)
- Xfce – lightweight desktop that reads desktop entries (Linux)
- desktop-file-validate – from freedesktop.org’s desktop-file-utils, checks a file against the specification (Linux)
Developers
- GDesktopAppInfo – the GLib and GIO class that loads desktop entries, usable from Python and other languages (C)
Reference
- Desktop Entry Specification – freedesktop.org’s specification of the format