You are not logged in.

#1 2017-01-25 19:23:54

cpoakes
Member
Registered: 2016-12-02
Posts: 108

Openbox menu - easily hide/disable menu items

I have a customised openbox menu and tinker with it often. The traditional way to hide or disable an item in the menu involves editting the menu.xml file and "commenting out" the xml section describing the menu item:

SNIPPET:

<!-- DISABLE
<item label="Terminal">
    <!-- Debian configured terminal -->
    <action name="Execute">
        <execute>x-terminal-emulator</execute>
    </action>
</item>
--> 

If you are familiar with this process, you may notice the error in this code snippet. Comments cannot be embedded; openbox pukes with an error. To correct the problem, the inner "-->" must be changed to something else (or the comment removed altogether). When re-enabled, the inner comment must be repaired (or added back).

A better alternative: change the name of the enclosing xml <item>..</item> tags to something unrecognised by the OB menu parser, like <null>..</null> or even the more descriptive <DISABLED.item>..</DISABLED.item>. It requires no enclosing comments; no altering/reverting embedded comments; is easily reverted with a sed command; and can be self-documenting with appropriate tag names.

As the xml is correctly formed, openbox ignores what it doesn't understand and loads the rest correctly. Likewise for obmenu which both ignores and preserves these unrecognized xml sections.

Furthermore, this is not limited to menus but also works in rc.xml. Typically I disable keys or mouse movements. But as an experiment, I disabled the entire <theme> section as <DISABLED.theme>; OB was well-behaved and fell back to the default values in /etc/xdg/openbox). As obconf and lxappearance-obconf muck about with the <theme> section, I expect incompatibility - but this is true of commenting out parts of the <theme> section as well.

Offline

#2 2017-01-26 07:45:36

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 9,093
Website

Re: Openbox menu - easily hide/disable menu items

Nice tip, thanks!

Moved to Scripts, Tutorials & Tips

Offline

#3 2017-01-26 07:47:30

ohnonot
...again
Registered: 2015-09-29
Posts: 5,592

Re: Openbox menu - easily hide/disable menu items

thanks for the hint, appreciated.
since this file is only parsed once when openbox starts or is reconfigured, there will be no added delay.
i like that.

cpoakes wrote:

As obconf and lxappearance-obconf muck about with the <theme> section, I expect incompatibility

i guess it will just create a complete new <theme> section?

Offline

#4 2017-01-27 04:57:24

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,654
Website

Re: Openbox menu - easily hide/disable menu items

Excellent tip! Thank you.
This makes scripted editing easier too.


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

Board footer

Powered by FluxBB