jhnmcknght: Professional Amateur

Universal Menu Item Disabling

The system and standard in place for handling menu items in Unix based desktop environments and window managers is a handy one developed by the fine folks at Freedesktop.org. If you look under /usr/share/applications in Linux and /usr/local/share/applications in FreeBSD and OpenBSD, you'll find a bunch of .desktop files. These are essentially what make up the applications that populate menus. Whether that's a menu under GNOME, MATE, XFCE, or any number of standalone window managers.

Most desktop environments provide their own menu editor which makes it easy to modify menu items beyond just hiding them but this article isn't going to cover other modifcations -- just disabling unnecessary items to streamline your menu.

The Good Part

When you disable menu items using a desktop environment's menu editor, this is what appears to happen behind the scenes (at least for me using MenuLibre):


As an example here's what my ~/.local/share/applications/debian-uxterm.desktop file looks like:

[Desktop Entry]
Comment=xterm wrapper for Unicode environments

Editing this file and commenting out NoDisplay=true or deleting this line entirely will predictably have this item show up under my menu in XFCE.

The Solution

First you'll want to find a menu item you want hidden from your menu so for me I'll use the example above. It turns out you don't have to do what menu editors do by copying the file over to ~/.local/share/applications and appending NoDisplay=true to it, it's even simpler than that so sit tight:

touch ~/.local/share/applications/debian-uxterm.desktop

Seriously -- that's it. Deleting this file will have it show up in the menu again. All you really need to do to disable menu items is find out what a program's corresponding .desktop file is under /usr/share/applications then use the touch command to recreate it under ~/.local/share/applications which creates an empty file and subsequently hides it from your menu.

So... That's It?

Yeah, seriously -- that's it.

Tags: #linux #bsd #desktop