Skip to content
Search

Gnome-menus

lastmod 2026-02-18created 2026-02-182 edits

gnome-menus is a library that implements freedesktop.org's Desktop Menu Specification, and generates and manages the application menu structure of the GNOME desktop environment.

Overview

It reads .desktop files and .menu XML files to build an application menu tree sorted into categories. The GNOME Shell app grid and other menu-based launchers use this library to display the list of installed apps.

How it works

  1. Reads the menu structure (category hierarchy) from .menu XML files.
  2. Matches apps to categories based on the Categories= field of .desktop files.
  3. Provides the sorted menu tree to applications.

Path

Description

/etc/xdg/menus/*.menu

XML files that define the menu structure

/usr/share/desktop-directories/*.directory

Category (directory) names and icon definitions

/usr/share/applications/*.desktop

Desktop entries for individual apps

<!DOCTYPE Menu PUBLIC "-//freedesktop//DTD Menu 1.0//EN"
 "http://www.freedesktop.org/standards/menu-spec/menu-1.0.dtd">
<Menu>
  <Name>Applications</Name>
  <Directory>X-GNOME-Menu-Applications.directory</Directory>

  <Menu>
    <Name>Accessories</Name>
    <Directory>Utility.directory</Directory>
    <Include>
      <And>
        <Category>Utility</Category>
        <Not><Category>System</Category></Not>
      </And>
    </Include>
  </Menu>

  <Menu>
    <Name>Graphics</Name>
    <Directory>Graphics.directory</Directory>
    <Include>
      <Category>Graphics</Category>
    </Include>
  </Menu>
</Menu>

.directory file example

[Desktop Entry]
Name=Accessories
Comment=Desktop accessories
Icon=applications-accessories
Type=Directory

Provided components

Component

Description

libgnome-menu-3.so

C library (GObject Introspection support)

GMenu module

Accessible from Python and others through GI bindings

Python usage example

import gi
gi.require_version('GMenu', '3.0')
from gi.repository import GMenu

tree = GMenu.Tree.new('gnome-applications.menu', GMenu.TreeFlags.NONE)
tree.load_sync()

root = tree.get_root_directory()
it = root.iter()
while True:
    item_type = it.next()
    if item_type == GMenu.TreeItemType.INVALID:
        break
    elif item_type == GMenu.TreeItemType.DIRECTORY:
        directory = it.get_directory()
        print(directory.get_name())

Specification

Description

Desktop Menu Specification

Standard defining menu structure and categories

Desktop Entry Specification

Standard for the .desktop file format

See also

Favorite site

author Zer0 sitemap