Skip to content
Search

Desktop Entry

lastmod 2026-02-18created 2023-07-0912 edits

Desktop Entry Specification

Both the KDE and GNOME desktop environments have adopted a similar format for "desktop entries", or configuration files describing how a particular program is to be launched, how it appears in menus, etc. It is to the larger community's benefit that a unified standard be agreed upon by all parties such that interoperation between the two environments, and indeed any additional environments that implement the specification, becomes simpler.

Categories

  • desktop-file-utils
    • desktop-file-validate - Validates that a .desktop file conforms to the freedesktop.org spec
    • desktop-file-install - Installs a .desktop file into the appropriate directory (/usr/share/applications/, etc.)
    • update-desktop-database - Refreshes the MIME type cache to update file associations

Directory

Desktop applications are installed in the following paths.

  • Current user: ~/.local/share/applications/
  • All user: /usr/share/applications

Sample

The basic template of the file has the following format.

[Desktop Entry]
Name=FooCorp Painter Pro
Exec=foocorp-painter-pro
Icon=foocorp-painter-pro
Type=Application
Categories=GTK;GNOME;Utility;

On Ubuntu 14.04, they are located at ~/.local/share/applications/*.desktop. (Global Applications are located at /usr/share/applications/*.desktop)

[Desktop Entry]
Version=1.0
Type=Application
Name=CLion
Icon=/home/username/Applications/clion-2016.3.2/bin/clion.svg
Exec="/home/username/Applications/clion-2016.3.2/bin/clion.sh" %f
Comment=The Drive to Develop
Categories=Development;IDE;
Terminal=false
StartupWMClass=jetbrains-clion

Other samples

Installation and DB update

If you already have a desktop file, you can add it with the following command. (Adding it manually is fine too)

sudo desktop-file-install extra/linux/Alacritty.desktop

Update with the following command.

sudo update-desktop-database

If there is a local directory:

update-desktop-database ~/.local/share/applications/

Updating icon files

Use gtk-update-icon-cache. The location is ~/.local/share/icons/hicolor/.

Add an icon for each size.

Then specify the icon by its file name without the extension.

[Desktop Entry]
...
Icon=Cursor

Desktop Action

Menus shown additionally when you right-click the icon can be added in a [Desktop Action {key}] Section:

[Desktop Action new-empty-window]
Name=New Empty Window
Exec=/home/zer0/Applications/Cursor-1.1.6-x86_64.AppImage --new-window %F
Icon=Cursor

Spec info

TryExec
What is the TryExec field in .desktop files? - Unix & Linux Stack Exchange
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).
A .desktop file with a non-empty TryExec field MUST NOT be autostarted if the value of the TryExec key does NOT match with an installed executable program.
Checks whether the specified executable actually exists on the system. If the file does not exist, the .desktop entry is not shown in the user's application menu or is disabled.
Version
The version of the Desktop Entry Specification. It is NOT the version of the software you are making a shortcut for! According to this page, you should enter 1.5. It is not a required field.
Categories
Used to determine which category the application belongs to in the user menu.
Path
Working Directory
X-LXQt-Need-Tray
A non-standard (custom) key used by the LXQt desktop environment that indicates whether a particular application needs an icon in the system tray (notification area).
X-GNOME-AutoRestart
If true, it autostarts ??
X-GNOME-Autostart-Phase=Initialization
Initialization - ??
StartupNotify
Defines whether the desktop environment should give the user visual feedback (e.g. a splash screen, a progress indicator) when the application starts.
If true, visual feedback (e.g. a spinning animation on the mouse cursor) is provided when the application starts.
StartupWMClass
Specifies the window class (Window Manager Class) that the desktop environment uses to identify the windows of a running application. This helps the desktop environment correctly map the application's windows to the .desktop file.
The value is the application's window class name (usually the application's X11 WM_CLASS property)
NoDisplay
??
Hidden
??

Categories

Main Categories

  • AudioVideo: Audio/video applications (e.g. media players, video editors)
  • Audio: Audio-only applications (e.g. audio players, audio editors)
  • Video: Video-only applications (e.g. video players, video editors)
  • Development: Development tools (e.g. IDEs, text editors)
  • Education: Educational applications (e.g. flash card programs, language learning programs)
  • Game: Game applications
  • Graphics: Graphics applications (e.g. image viewers, photo editors)
  • Network: Network-related applications (e.g. web browsers, remote desktop programs)
  • Office: Office applications (e.g. word processors, spreadsheets)
  • Science: Science-related applications (e.g. calculators, simulation software)
  • Settings: Settings applications (e.g. system settings, configuration tools)
  • System: System-related applications (e.g. terminals, file managers)
  • Utility: Utility applications (e.g. text editors, notepads)
  • HardwareSettings: Hardware-related settings (e.g. printer settings, display settings)
  • Personal: Personal applications (e.g. calendars, personal information managers)

Additional Categories

  • Building: Build tools (e.g. build systems, compilers)
  • Debugger: Debuggers
  • GUIDesigner: GUI designers
  • Profiling: Profiling tools
  • RevisionControl: Version control tools
  • Translation: Translation tools
  • Calendar: Calendar applications
  • ContactManagement: Contact management applications
  • Database: Database management applications
  • Dictionary: Dictionary applications
  • Chart: Chart applications
  • Email: Email applications
  • Feed: Feed reader applications
  • FileTransfer: File transfer applications
  • HamRadio: Amateur radio applications
  • IRCClient: IRC clients
  • InstantMessaging: Instant messaging applications
  • News: News reader applications
  • P2P: P2P applications
  • RemoteAccess: Remote access applications
  • Telephony: Telephony applications
  • WebBrowser: Web browser applications
  • TextEditor: Text editors
  • WordProcessor: Word processors
  • Application: Other applications
  • Applet: Applets
  • Shell: Shell applications
  • Accessibility: Accessibility tools
  • Calculator: Calculator applications
  • Clock: Clock applications
  • TextTools: Text tool applications
  • FileManager: File management applications
  • TerminalEmulator: Terminal emulators
  • Archiving: Compression tools
  • Compression: Compression tools
  • Filesystems: File system tools
  • Monitor: Monitoring tools
  • Security: Security tools
  • Accessibility: Accessibility tools

Variables

Autostart Spec info

Storage folders:

  • /etc/xdg/autostart
  • ~/.config/autostart/

The program for registering via GUI in gnome is gnome-session-properties.

Running in a GNOME Shell terminal

Since it launches the terminal emulator directly, set Terminal=false so that a separate terminal is not launched. Roughly, use it like this:

[Desktop Entry]
Version=1.0
Terminal=false
Type=Application
Name=AnswerML2
Exec=/usr/bin/gnome-terminal --tab -e "/home/hogonets/bin/answer-ml2.sh"
Icon=/usr/bin/share/icon.svg
Categories=Utility;

See also

Favorite site

author Zer0 sitemap