OPENBOX HOME

ob   Openbox Dynamical Root Menu   ob

For those Openbox users who want a dynanamical Root Menu, that is, a right click menu that automatically picks up newly installed Linux apps, I recommend Daniel Trizen's Obmenu-generator.    Obmenu-generator, should not be confused with obmenugen, which is different and much less feature endowed. Obmenu-generator is a simple, lightweight (367 KB), easily configurable Perl script that generates a valid, full, dynamical Openbox xml-menu based upon the information present in *.desktop application files. It has few dependencies and is very fast and accurate. Most pure Linux apps automatically install a desktop file, and such apps will generally appear in their stipulated categories default in most menus. Wine, Java and apps created locally by special scripts, generally do not automatically appear in menus after installation. To appear in a menu, they require the installer, himself, create an application desktop file. See Openbox Guide - Desktop Files . Obmenu is no exception to these rules. An example of an (edited) Obmenu-generated menu is below-right.

At this time the only Debian file for Obmenu-generator known to me is one in the Sparky Linux repository. See the Addendum below for using it to install Obmenu-generator. Otherwise, one can install it using Trizen's copy from the github link identified above. First make sure that build-essential, cpanminus and git are installed: sudo apt-get install build-essential cpanminus git. Then, apply the following sequence of terminal commands:

    git clone git://github.com/trizen/obmenu-generator
    sudo cp obmenu-generator/obmenu-generator /usr/bin
    sudo cp -r obmenu-generator/schema.pl ~/.config/obmenu-generator
    sudo cpanm Linux::DesktopFiles
    sudo cpanm Data::Dump
    sudo chmod 777 /usr/bin/obmenu-generator.

To set a dynamical version of the Root Menu, put the following in the terminal (leaving out "-i" if you want an icon-less menu):
    obmenu-generator -p -i.

obmenu-generator menu

Obmenu-generator works by creating an upfront file, ~/.config/obmenu-generator/schema.pl, to replace ~/.config/openbox/menu.xml as the file for editing the menu. I've tried distros in the past that created a schema file to make a dynamic openbox root menu, but found them lacking simplicity and being overly restrictive in what kind of static entries could be made. Obmenu-generator is different in both instances. Configuring schema.pl, including adding new dynamical categories, is for the most part very easy. Everything possible with a static root menu is still possible with the Obmenu. What follows is a precise description for editing each of the sections pictured in the enhanced Obmenu pictured on the right.

Default Categories

The crux of the obmenu-generator menu are 11 (plus 5 special unactivated categories not pictured) pre-programmed categories. They are completely dynamic in that their contents instantly change to reflect the addition of a new app (*.desktop file). So there is nothing configurable here, or needing to be configured. The lists appear to be very accurate in their reflection of the categories listed for an app and the layout of apps in the lists is very friendly - alphabetical regardless of case. In the past I've had menus list every app on the computer plus everything under the kitchen sink in the "other" category. Notice that the menu picture here does not even show the "other" category, which is inluded in the default categories, because none of the apps installed lists category="other", and the other 10 listed categories are sufficient to include everything else. In general, a category does not appear on the menu if there are no installed apps listed in that category. New categories can be created by simply adding an appropriate line in the schema file. For example, to add the Wine category, we simply added the following line at the end of the categories section of schema.pl:
    {cat => ['wine',     'Wine',    '/usr/share/icons/Black-Diamond/scalable/apps/wine-doors.png']}

Now a regular static Openbox Root Menu can be configured to include a catch-all "Applications" category, which in turn consists of a dynamical sub-category list. See any of the following: Lxlinux - Menu, Openbox Menu, After Openbox for details. Not much different from the situation here. However, there is something appealing, not to mention slightly faster, about just right clicking the desktop and having a complete set of dynamical categories open-up to slide the tool-tip through just once, instead of having to do it twice, to reach an app launch point.

Adding Items or Pipemenus

Adding a new item (application) or a new pipemenu requires a one line edit to supply information for 3 fields: exec, name, icon . The following examples illustrate the syntax and nature of the two types of entries:

    {item => ['pmrp-vlc', 'Radio Player', 'radio']},
    {pipe => ['python /opt/menu/dir-menu.py', 'Places-Comp', '/usr/share/icons/directory.png']}, .

If a generic name is given for an icon, the program will try to match it with an icon from the icon theme chosen in lxappearance. Otherwise, giving the path to a specific icon will choose that icon.

Adding Special User Categories

If there are not many applications in the category, then it is easiest to just make an item entry for each app between the category introduction and exit tags. For the scrot category in the above menu, it looks like the following:

scrot-obmenu
    {begin_cat => ['Scrot -q 90', '/usr/share/icons/scshoot.png']},
       {item => ['scrot -q 90 -e "mirage $f"', 'Now', '/usr/share/icons/scrot0.png']},
       {item => ['scrot -q 90 -d 15 -e "mirage $f"', 'In 15 Seconds', '/usr/share/icons/scrot-15.png']},
       {item => ['scrot -q 90 -s -e "mirage $f"', 'Area (drag mouse)', '/usr/share/icons/scrot-area.png']},
       {item => ['scrot -q 90 -u -e "mirage $f"', 'Window (click win)', '/usr/share/icons/scrot-wndw.png']},
       {item => ['scrot -q 90 -m -e "mirage $f"', 'Multi-Monitor', '/usr/share/icons/scrot-mm.png']},
    {end_cat => undef},

Adding Submenus

It happens that sometimes a user has a long special submenu (*.xml file) all scribed out. Can it be added to the obmenu-generator menu without re-scribing it to fit the format described in the previous section? The answer is "yes", which is the main reason that I now so heartedly embrace the obmenu-generator approach. I have several such menus which can be added to the classical static Openbox Root Menu with one line, and wanted something similar here. The recipe that I use follows.

Among Openboxes features is the ability to creat keybindings for any menu that follows the freedesktop standard. All that is required is making 2 simple edits in rc.xml for each menu. For example, to set up the Bash Menu (~/.config/openbox/bash.xml), which at the moment has over 40 entries and only gets bigger, I added to the menu section of ~/.config/openbox/rc.xml the following line:

    <file>/home/me/.config/openbox/bash.xml</file> ,

and to the section <!-- Keybindings for running applications --> of rc.xml, I added the following:

    <keybind key="C-A-b">
      <action name="ShowMenu">
        <menu>bash</menu>
      </action>
    </keybind> .

We can now launch the Bash Menu by pressing the key combination: Ctrl+Alt+b. For more information and discussion about menu keybindings in Openbox, see Openbox Menu.

#!/bin/bash
xdotool key "ctrl+alt+b" &
exit

bash-menu

The small very useful linux tool, xdotool, can be used to put Bash Menu on the Root Menu. If not already installed, then do sudo apt-get install xdotool . Copy and paste the small bash script on the left to a text file, name it bash-menu and save it in /usr/local/bin (can be saved anywhere on-the-path). Be sure bash-menu is executable and add it to schema.pl as an item:

    {item => ['bash-menu', 'Bash Menu', '/usr/share/icons/bash.png']}, .

openbox-config
Openbox Config Submenu
End of story. Bash Menu is now on the menu and left-clicking it will launch a new menu with the skeletons of 40+ terminal commands, any one of which will print on an open terminal when clicked. If interested, a copy of bash.xml can be downloaded from this website: wget http://lxlinux.com/bash.xml .

Obgenmenu (Openbox Config)

Openbox Config is a special category built into the exec file, /usr/bin/Obmenu-generator. The items in it can be edited by editing Obmenu-generator. A slightly edited version, which is what you get if you download obmenu-generator from this site (wget http://lxlinux.com/obmenu-generator), is pictured on the right. Here is where the user chooses the nature of the general menu and can launch the main editing files. My addition was to add links to additional desktop configuration tools, so that all the main desktop editing tools were together in the same category.

Since the main point of Obmenu-generator is to create a dynamical menu and that is done with the terminal command given above, I'm not sure what the point is of the "Generate..." section. To go back to a static menu, the user needs only to replace the menu.xml generated by Obmenu-generator by any menu.xml constructed for a static root menu.

Addendum

Obmenu-generator is now in the Sparky Linux Repository, which has a large number of useful special tools. The Sparky Linux Repository can be added to your sources directory by creating a sparky.list file:

    sudo geany /etc/apt/sources.list.d/sparky.list .

Type the following into sparky.list:

    ## sparky
    deb http://sparkylinux.org/repo testing main .

Save the file and leave the editor. Update package list, install the public key via the package manager and install obmenu-generator using apt-get (or synaptic):

    sudo apt-get update
    sudo apt-get install sparky-keyring
    sudo apt-get update
    sudo apt-get install obmenu-generator .

The new "Root Menu" will probably be the Obmenu-generator static one, so bring it up and click "Advanced Settings>Obmenu-Generator>Generate a pipe menu ..." to get a dynamical one. The original static root menu is saved as ~/.config/openbox/menu.xml.ba . Configuring the new dynamical menu is done in ~/.config/obmenu-generator/schema.pl as described above. In order to eliminate potential future update problems, you may want to inactivate the Sparky repo after installing obmenu-generator, if your system is not based upon Debian Testing.

You can download the complete Sparky Linux Repository (58.4 MB) with:

     git clone git://git.code.sf.net/p/sparkylinux/code sparkylinux-code .

Installation of Obmenu-generator can be then also achieved directly from the files in the obmenu-generator folder in that download.

OPENBOX HOME