LinuxCommandLibrary

desktop-file-validate

Validate desktop entry files

SYNOPSIS

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

PARAMETERS

-h, --help
    Show summary of options and exit.

-V, --version
    Show version of program and exit.

DESCRIPTION

desktop-file-validate is a command-line tool from the desktop-file-utils package that checks .desktop and .directory files for adherence to the freedesktop.org Desktop Entry Specification (version 1.1). These files, found in directories like /usr/share/applications/ and ~/.local/share/applications/, define application menu entries, launchers, desktop shortcuts, and MIME handlers used by environments such as GNOME, KDE, XFCE, and LXDE.

The validator examines syntax, mandatory fields (Type, Name, Exec), optional keys (Icon, Categories), encoding (must be UTF-8), proper escaping in values, valid section headers ([Desktop Entry]), no duplicate keys, correct boolean formats, and rules like requiring TryExec or Path for certain Exec expansions. Errors, such as invalid categories or malformed URLs, are printed to stderr with precise locations.

Ideal for developers, packagers, and sysadmins, it ensures cross-desktop compatibility. Use in build pipelines (e.g., make check) or maintenance scripts: desktop-file-validate $(find /usr/share/applications -name '*.desktop'). Silent on valid files; non-zero exit on failures enables automation.

CAVEATS

Outputs errors only to stderr; does not verify existence of Icon or Exec targets, only format/spec. Strict checks may flag functional legacy files. Processes files sequentially; no stdin support.

EXIT STATUS

0 if all files valid, 1 if any errors found.

STANDARDS

Implements Desktop Entry Specification 1.1; supports .desktop and .directory files.

SEE ALSO

Copied to clipboard