LinuxCommandLibrary

desktop-file-install

Install desktop entry files correctly

SYNOPSIS

desktop-file-install [OPTION...] FILE...

PARAMETERS

--dir=DIR
    Install FILE to directory DIR instead of default.

--local
    Install to user-local directory ~/.local/share/applications.

--delete-original
    Delete original FILE after successful installation.

--vendor=ID
    Prefix .desktop and .directory names with vendor ID.

--mode=MODE
    Set install mode to user or system (default: system).

-h, --help
    Display help and exit.

-V, --version
    Output version information and exit.

DESCRIPTION

The desktop-file-install command is a utility from the desktop-file-utils package used to install .desktop files, which are standard freedesktop.org desktop entry files defining applications for Linux desktop environments. These files specify an application's name, icon, executable command, categories, keywords, and more, enabling integration into menus, launchers, and search indexes.

It validates the syntax and structure of the input file using rules from the Desktop Entry Specification, ensuring compliance before installation. The command copies the file to system-wide directories like /usr/share/applications or user-local ~/.local/share/applications, depending on options. Validation catches common errors such as invalid keys, missing required fields (e.g., Name, Exec), or incorrect encoding.

Primarily used in packaging scripts (e.g., RPM, DEB post-install) to deploy application shortcuts. For system-wide installs, root privileges are typically needed. After installation, running update-desktop-database rebuilds caches for immediate menu visibility. It supports vendor prefixing for branded files and mode selection for user vs. system scopes, making it essential for cross-desktop compatibility in GNOME, KDE, XFCE, and others.

CAVEATS

Requires root for system-wide installs without --local. Does not rebuild menu caches; run update-desktop-database afterward. Files must pass validation or installation fails. Avoid --delete-original in scripts unless confirmed safe.

EXAMPLES

desktop-file-install --dir=/usr/share/applications myapp.desktop
desktop-file-install --local --delete-original ~/Desktop/myapp.desktop
desktop-file-install --vendor=com.example --mode=user myapp.desktop

VALIDATION

Automatically invokes validation checks per Desktop Entry Specification. Common fixes not applied; use desktop-file-edit for manual tweaks.

HISTORY

Developed as part of desktop-file-utils for freedesktop.org standards around 2001-2002. Evolved with Desktop Entry Spec v1.0+ to support modern features like StartupWMClass and keywords. Maintained in most distros for consistent app deployment.

SEE ALSO

Copied to clipboard