LinuxCommandLibrary

xdg-desktop-menu

Install or uninstall desktop menu entries

TLDR

Install an application to the desktop menu system

$ xdg-desktop-menu install [path/to/file.desktop]
copy

Install an application to the desktop menu system with the vendor prefix check disabled
$ xdg-desktop-menu install --novendor [path/to/file.desktop]
copy

Uninstall an application from the desktop menu system
$ xdg-desktop-menu uninstall [path/to/file.desktop]
copy

Force an update of the desktop menu system
$ xdg-desktop-menu forceupdate --mode [user|system]
copy

SYNOPSIS

xdg-desktop-menu install [--mode mode] [--noupdate] file ...
xdg-desktop-menu uninstall [--mode mode] [--noupdate] file ...
xdg-desktop-menu forceupdate [--mode mode]
xdg-desktop-menu { --help | --version }

PARAMETERS

install
    Installs the specified menu files. The files can be .menu files (defining menu structure) or .directory files (defining menu categories).

uninstall
    Uninstalls the specified menu files, removing them from the system's menu configuration.

forceupdate
    Forces an immediate update of the desktop menu cache, regenerating the menu without requiring an install/uninstall operation.

--mode {user|system}
    Specifies the installation mode. user installs files for the current user only. system installs files for all users (requires root privileges). The default is user.

--noupdate
    Prevents the menu cache from being updated immediately after an install or uninstall operation. This can be useful for batch operations.

file ...
    One or more paths to .menu or .directory files to be installed or uninstalled.

--help
    Displays a help message and exits.

--version
    Shows version information and exits.

DESCRIPTION

xdg-desktop-menu is a utility that allows applications to install and uninstall menu entries compliant with the freedesktop.org Desktop Menu Specification. It is part of the xdg-utils package, a set of command-line tools that assist applications with various desktop integration tasks.

This command helps ensure that applications correctly appear in a user's desktop environment's main application menu. It works by managing menu files (typically .menu and .directory files) that describe the structure and categories of application menus. When a menu file is installed, xdg-desktop-menu registers it with the system, and desktop environments then use this information to build and display the hierarchical application menu that users interact with. It abstracts the differences between various desktop environments, providing a standardized way to manage menu entries.

CAVEATS

Although xdg-desktop-menu provides a standardized interface, the actual integration and rendering of menus can still vary between desktop environments. Some desktop environments might have their own specific mechanisms or might not fully utilize the XDG Desktop Menu Specification directly for their primary menu, although most modern ones do to some extent. Proper functioning also relies on the xdg-utils package being correctly installed and configured on the system.

XDG DESKTOP MENU SPECIFICATION

The core of xdg-desktop-menu's functionality is based on the freedesktop.org Desktop Menu Specification. This specification defines how applications can be categorized and organized within hierarchical menus, using .menu files to describe menu structures and .directory files to represent menu categories.

MENU FILE TYPES

xdg-desktop-menu primarily deals with two types of files: .menu files, which define the structure of a menu and include or exclude applications based on their categories; and .directory files, which represent a menu category (e.g., 'Graphics', 'Development') and provide an icon and name for that category in the menu.

INTEGRATION WITH PACKAGE MANAGERS

Typically, application developers or package maintainers use xdg-desktop-menu (or similar tools like desktop-file-install) during the installation process of a software package. This ensures that when a user installs an application, its entry correctly appears in the desktop environment's application menu without manual intervention.

HISTORY

The xdg-desktop-menu command is part of the xdg-utils project, initiated by freedesktop.org. This project aims to standardize common desktop integration tasks across various Linux and Unix desktop environments (like GNOME, KDE, XFCE, LXQt, etc.). It emerged from the need to provide consistent application behavior and integration regardless of the underlying desktop environment, thereby simplifying application development and deployment on the Linux desktop.

SEE ALSO

Copied to clipboard