How does the menu categorize apps

Many Ubuntu based distros that use a traditional menu have categories. (accessories,graphics,internet, office, etc)

When I first saw these, I thought they were preset categories that someone manually made, but then I install an app like Microsoft Edge or Chrome, and I see the apps automatically in the internet category, I install grub customizer, and it’s automatically in the administration category, I install Gparted, and it’s automatically in the adminstarion category too.

I tested this on Linux mint, Xubuntu and Raspberry PI OS(I know it’s based on Debian not Ubuntu) I also believe that older versions of Ubuntu had the same thing.

My question is how does Linux know where to put new apps? Is it an online list of apps, or is it a local list in the os, or does the app I install contain one line of code that tells linux what category it should be in?

What is it that linux refers to?

Asked By: THE_PERSON4204

||

An application comes with a .desktop-file which includes a line with

Categories=...

The information in this line is used by files in /etc/xdg/menus, these files define the organisation of the menu, directories, there order and which .desktop-files should be displayed under a directory with a certain name.

Here an example, the .desktop-file for Firefox has a line

Categories=GNOME;GTK;Network;WebBrowser;

and a file in /etc/xdg/menus includes the following snippet:

    <Menu>
        <Name>Internet</Name>
        <Directory>kf5-internet.directory</Directory>
        <Include>
            <And>
                <Category>Network</Category>
                <Not><Category>X-KDE-More</Category></Not>
            </And>
        </Include>

It means that the directory Internet in the menu should include .desktop-files that have Network in it’s Categories=...-line which is the case for firefox.desktop.

You might have a bit different files in /etc/xdg/menus than I and the corresponding snippet might be a bit different, it depends on your desktop environment, but with my example you can see how it works under the hood.

For deeper insight you can see the Desktop Menu Specification from freedesktop.org, here the latest version.

Answered By: mook765
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.