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...] [EXECUTIVE]

PARAMETERS

EXECUTIVE
    An optional executable file from which gendesk can attempt to infer information like the application name or execution command.

--name NAME
    Sets the Name field in the .desktop file, which is the application's displayed name.

--exec COMMAND
    Sets the Exec field, specifying the command to execute when the application is launched. Arguments can be included.

--icon ICON_PATH
    Sets the Icon field, pointing to the application's icon file (e.g., a PNG, SVG, or icon theme name).

--type TYPE
    Sets the Type field. Common types include Application (for programs), Link (for URLs), or Directory.

--comment COMMENT
    Sets the Comment field, providing a short description or tooltip for the application.

--category CATEGORY
    Adds a category to the Categories field (e.g., Utility, Game). This option can be used multiple times.

--terminal
    Sets Terminal=true, indicating the application should be run in a terminal window.

--nodisplay
    Sets NoDisplay=true, meaning the application should not be shown in menus, but can still be launched programmatically.

--hidden
    Sets Hidden=true, marking the application as deprecated or no longer relevant.

--mimetype MIME_TYPE
    Adds a MIME type to the MimeType field (e.g., text/plain). This option can be used multiple times for multiple types.

--output FILE
    Specifies the output file path where the generated .desktop content will be saved, instead of printing to standard output.

--user
    If supported by the implementation, installs the .desktop file for the current user (typically in ~/.local/share/applications/).

--all-users
    If supported, installs the .desktop file system-wide for all users (typically in /usr/share/applications/).

--help
    Displays a brief usage message and exits.

--version
    Displays version information and exits.

DESCRIPTION

The gendesk command is a utility designed to simplify the creation of freedesktop.org compliant .desktop files. These files are crucial for desktop environments like GNOME, KDE, and XFCE, as they provide metadata about applications, including their name, icon, execution command, categories, and MIME types.

Instead of manually crafting complex .desktop files, gendesk allows users or package maintainers to generate them from simpler input, often by deriving information from existing executable files or through concise command-line arguments. It helps automate the process of creating proper application launchers, ensuring applications integrate smoothly into the desktop environment.

CAVEATS

The exact set of supported options and their behavior can vary slightly between different implementations of gendesk across Linux distributions. For full integration, generated .desktop files often require placement in standard directories (e.g., /usr/share/applications/ or ~/.local/share/applications/) and a cache refresh via update-desktop-database.

.DESKTOP FILE FORMAT

.desktop files are INI-like configuration files used by XDG compliant desktop environments to describe applications, documents, and directories. They contain metadata such as Name, Exec, Icon, Categories, and MimeType, enabling the desktop environment to display applications in menus, handle file associations, and launch programs correctly.

INTEGRATION WITH DESKTOP ENVIRONMENTS

By generating standardized .desktop files, gendesk ensures applications are correctly represented and launched within various desktop environments. This includes proper menu integration, icon display, and association with relevant file types, contributing to a seamless user experience on Linux desktops.

HISTORY

gendesk emerged as a convenience script to automate the creation of .desktop files, which became the standard for application launchers in Freedesktop.org compliant desktop environments (GNOME, KDE, XFCE). Its development aligns with the broader effort to standardize Linux desktop components, often appearing as part of development utility packages (like devscripts on Debian/Ubuntu) or build tools, simplifying packaging processes for application developers and maintainers.

SEE ALSO

Copied to clipboard