Organizing freedesktop Desktop Entries in Linux

This took me a while to get down — given the complexity introduced here in the number of possible locations for things to be configured at a user and global level — but I have been able to create desktop directory entries and have them appear in whiskermenu properly. I highly recommend not to use a tool sure as alacarte or xame, as they may introduce more complexity and complicate your configuration files to the point that they are impossible to edit and produce any results in your menu.

Whiskermenu with Application Directories Screenshot

➜  ls /home/nick/.local/share/desktop-directories 
alacarte-made-1.directory  chrome-apps.directory       gps-apps.directory
alacarte-made.directory    development-apps.directory  settings-apps.directory
chat-apps.directory        game-apps.directory

Here’s the contents of game-apps.directory as an example to be followed for all the category files you create:

[Desktop Entry]
Comment=
Type=Directory
Name=Games
Icon=/home/nick/Pictures/icons/IconScanner/png/GameCenter.png

My .menu files are stored in a subdirectory called applications-merged because of the fact that I used various GUI tools to create my entries. Placing your .menu files in the parent menus directory should suffice.

➜  ls /home/nick/.config/menus/applications-merged 
chat-apps.menu         game-apps.menu  theplatform-apps.menu  xdg-desktop-menu-dummy.menu
development-apps.menu  gps-apps.menu   user-chrome-apps.menu

The freedesktop .menu file looks as follows, for our games category example:

<!DOCTYPE Menu PUBLIC "-//freedesktop//DTD Menu 1.0//EN"
    "http://www.freedesktop.org/standards/menu-spec/menu-1.0.dtd">
<Menu>
    <Name>Applications</Name>
<Menu>
    <Name>game-apps</Name>
    <Directory>game-apps.directory</Directory>
    <Include>
        <Filename>American Truck Simulator.desktop</Filename>
        <Filename>steam.desktop</Filename>
        <Filename>m64py.desktop</Filename>
        <Filename>desmume.desktop</Filename>
        <Filename>dolphin-emu.desktop</Filename>
        <Filename>PPSSPP.desktop</Filename>
        <Filename>chrome-ikffjkehicicbeijfeneenheeijonfjc-Default.desktop</Filename>
        <Filename>flightgear.desktop</Filename>
    </Include>
</Menu>
</Menu>

These *.desktop files must exist in an applications directory:

➜  ls /usr/share/applications | grep steam 
steam.desktop

and the contents of one should look something like

[Desktop Entry]
Name=Steam
Comment=Application for managing and playing games on Steam
Exec=/usr/bin/steam %U
Icon=steam
Terminal=false
Type=Application
Categories=Network;FileTransfer;Game;
MimeType=x-scheme-handler/steam;
Exec=steam steam://open/friends

Finally, you will need to add an entry to a .menu file similar to the following. My full menu file’s path is /home/nick/.config/menus/xfce-applications.menu since I am using XFCE as my desktop environment:

<Menu>
		<Name>game-apps</Name>
		<Directory>game-apps.directory</Directory>
		<Layout>
			<Merge type="menus"/>
			<Filename>American Truck Simulator.desktop</Filename>
			<Filename>steam.desktop</Filename>
			<Separator/>
			<Filename>dolphin-emu.desktop</Filename>
			<Filename>desmume.desktop</Filename>
			<Filename>m64py.desktop</Filename>
			<Filename>PPSSPP.desktop</Filename>
			<Separator/>
			<Filename>flightgear.desktop</Filename>
			<Separator/>
			<Filename>chrome-ikffjkehicicbeijfeneenheeijonfjc-Default.desktop</Filename>
			<Merge type="files"/>
		</Layout>
	</Menu>
	<Layout>
		<Merge type="menus"/>
		<Menuname>game-apps</Menuname>
	</Layout>
</Menu>

Leave a Reply

Your email address will not be published. Required fields are marked *