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, and such apps will instantly appear in the stipulated default Obmenu-generator categories. Apps, such as most Wine and Java apps, generally do not automatically appear in the menu after installation. They require a *.desktop (See Openbox Guide - Desktop Files. ) be made either from scratch, or by using a good GUI such as Lxmed. An example of an (edited) Obmenu-generated menu is on the right.

There doesn't seem to be a Debian version of Obmenu-generator, so installation requires a little ingenuity (See Addendum below.). The easiest way is to first make sure that build-essential, cpanminus and git are installed: sudo apt-get install build-essential cpanminus git. Follow with 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:

    obmenu-generator -p -i .

Leave out "-i" if you want an icon-less menu.

obmenu-generator menu

Obmenu-generator works by creating an upfront schema file, which replaces 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 ~/.config/obmenu-generator/schema.pl is for the most part very easy, and I have found everything possible with a static root menu is still possible with the dynamical obmenu-generator root menu. I will next relay details for configuring each of the sections identified in the picture on the right.

Default Categories

The crux of the obmenu-generator menu are 12 (plus 5 special unactivated categories in the pictured menu) pre-programmed category sets. 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 11 listed categories are sufficient to include everything else.

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

obgenmenu
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']}, .

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 the 2 openbox GUI's, obconf and lxappearance, and duplicate (accidently) 2 openbox restarts, so that all the main openbox 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 achieved directly from the files in the obmenu-generator folder in that download.

OPENBOX HOME