LinuxCommandLibrary

gendesk

Create desktop entry files

TLDR

Create a .desktop file named app

$ gendesk -n --name "[app]" --exec "/[path/to/app]" --icon "/[path/to/icon.png]" --comment "[This is application]"
copy

Create a .desktop file named app, do not display any output, and overwrite it if it exists
$ gendesk -q -f -n --name "[app]" --exec "/[path/to/app]" --icon "/[path/to/icon.png]" --comment "[This is application]"
copy

Display help
$ gendesk [[-h|--help]]
copy

SYNOPSIS

gendesk [options] [template.desktop]

PARAMETERS

-h, --help
    Display help message and exit

-V, --version
    Display version information and exit

-p PKGNAME, --pkgname PKGNAME
    Set package name; auto-fills GenericName, Comment, Keywords

-P PKGBASE, --pkgbase PKGBASE
    Set package base name for shared metadata

-n NAME, --name NAME
    Set application display name (Name= field)

-f FIELD=VALUE, --field FIELD=VALUE
    Set any desktop field (e.g., Exec=foo); repeatable

--template TEMPLATE
    Read initial fields from existing .desktop template file

-o FILE, --output FILE
    Write output to FILE instead of stdout

--dir DIR
    Base directory for relative Icon and other paths

--no-interactive
    Skip interactive prompts, use defaults

DESCRIPTION

Gendesk is a lightweight command-line utility designed to generate standard .desktop files used by Linux desktop environments (like GNOME, KDE, XFCE) to define application launchers, menu entries, icons, and MIME associations. These files follow the XDG Desktop Entry Specification and are essential for integrating software into graphical environments.

Primarily used in Arch Linux PKGBUILDs and AUR packaging workflows, gendesk simplifies creating compliant .desktop files without manual editing of INI-style syntax. Users specify fields via options or templates, and it auto-populates sensible defaults based on package metadata (e.g., deriving GenericName from pkgname).

Key features include setting fields like Name, Exec, Icon, Categories, Comment, and more. It supports interactive mode for querying values, reading from template files, and outputting to files or stdout. Generated files can be installed to /usr/share/applications/ via make install or packaging scripts.

This tool saves time for packagers, ensures consistency, and reduces errors in desktop integration. Always validate output with desktop-file-validate.

CAVEATS

Generated files must be validated with desktop-file-validate(1). Primarily for Arch packaging; may need manual tweaks for complex apps. Interactive mode prompts for input if fields missing.

TYPICAL USAGE

gendesk -p myapp -n 'My App' --field Exec=myapp --field Icon=myapp --field Categories=Utility; or interactively: gendesk -p myapp

INTERACTIVE MODE

Run without options or with -p; prompts for Name, Exec, Icon, Categories, etc., using editor if $EDITOR set.

HISTORY

Developed by xyproto (Alexander von Ruppert) around 2013 for Arch Linux AUR/PKGBUILD workflows. Available in community repo as gendesk package; actively maintained on GitHub with focus on simplicity and spec compliance.

SEE ALSO

Copied to clipboard