How Linux Desktop Entries Create Application Menus
This article explores how the Linux operating system uses desktop
entries to construct graphical application menus. Linux desktop
environments rely on standardized configuration files known as
.desktop files to locate, identify, and categorize
installed software. By reading these metadata files from designated
directories and applying desktop integration specifications, system menu
systems automatically organize applications into clear, launchable menu
hierarchies.
The Freedesktop.org Standard
Linux application menus do not use a centralized registry. Instead, modern desktop environments such as GNOME, KDE Plasma, and XFCE follow the Desktop Entry Specification defined by Freedesktop.org (also known as the XDG standard). This cross-desktop standard ensures that an installed application appears consistently across any graphical environment without requiring custom configuration for each window manager.
Standard File Locations
Desktop environments monitor specific filesystem paths to discover available software. When looking for desktop entries, the system scans two primary types of locations:
- System-wide directories:
/usr/share/applications/and/usr/local/share/applications/contain entries for programs available to all users on the machine. - User-specific directories:
~/.local/share/applications/contains entries available only to the current user, allowing individual customization without administrative privileges.
Any valid .desktop file placed in these directories is
read by the desktop environment's menu generator.
Anatomy of a .desktop
File
A desktop entry is a plain text configuration file formatted with
key-value pairs grouped under a [Desktop Entry] header. The
core keys responsible for generating the menu items include:
- Type: Defines the entry type, typically
Application. - Name: The user-facing label shown in the menu
(e.g.,
Firefox Web Browser). - Exec: The absolute path or command-line binary executed when the user clicks the menu item.
- Icon: The name or absolute path of the icon displayed next to the application name.
- Categories: Semicolon-separated values that
designate where the application belongs (e.g.,
Network;WebBrowser;). - NoDisplay: A boolean value (
trueorfalse) that tells the system whether to hide the entry from the menu while still associating it with file types.
Menu Generation and Categorization
Desktop menus rely on the XDG Menu Specification to map applications
to visual menu trees. A separate XML-based menu definition file (usually
found in /etc/xdg/menus/) defines categories such as
"Development," "Graphics," "Internet," and "Office."
When the desktop environment loads, it processes the
Categories key inside every .desktop file. For
instance, if an entry includes
Categories=AudioVideo;Player;, the system automatically
assigns that entry to the "Multimedia" or "Sound & Video"
sub-menu.
Dynamic Updates
Application menus update automatically when new software is installed
or removed. Package managers like apt, dnf, or
pacman drop new .desktop files into
/usr/share/applications/ during installation. Modern
desktop environments use filesystem monitoring mechanisms (such as
inotify) or update utilities like
update-desktop-database to detect these file changes
instantly, rebuilding the application menu in real time without
requiring a system reboot or desktop restart.