Goal: Explaining openbox menu.xml configuration

Reading

There is also a whole article for this.


Default rc.xml.

The default ~/.config/openbox/rc.xml looks similar to this below:

  <menu>
    <file>menu.xml</file>
    <hideDelay>200</hideDelay>
    <middle>no</middle>
    <submenuShowDelay>100</submenuShowDelay>
    <submenuHideDelay>400</submenuHideDelay>
    <showIcons>yes</showIcons>
    <manageDesktops>yes</manageDesktops>
  </menu>

It simply show something like this:

openbox Menu: SUSE default

My openSUSE’s openbox come without ~/.config/openbox/menu.xml. We need to create it manually.

Source


You can find the default at /etc/xdg/openbox/menu.xml. However, this is a manually created ~/.config/openbox/menu.xml.

<?xml version="1.0" encoding="utf-8"?>
<openbox_menu xmlns="http://openbox.org/3.4/menu">
    <menu id="system-menu" label="System">
        <item label="Openbox Configuration Manager">
            <action name="Execute">
                <command>obconf</command>
                <startupnotify>
                    <enabled>yes</enabled>
                </startupnotify>
            </action>
        </item>
        <item label="Reconfigure Openbox">
            <action name="Reconfigure"/>
        </item>
    </menu>
    <menu id="root-menu" label="Openbox 3">
        ...
        <separator label="System"/>        
        <menu id="system-menu"/>
        <separator/>
        <item label="Log Out">
            <action name="Exit">
                <prompt>yes</prompt>
            </action>
        </item>
    </menu>
</openbox_menu>

openbox Menu: system

Note that the system menu is recreated manually.

<?xml version="1.0" encoding="utf-8"?>
<openbox_menu xmlns="http://openbox.org/3.4/menu">
    <menu id="system-menu" label="System">
        ...
    </menu>
    <menu id="root-menu" label="Openbox 3">
        ...       
        <menu id="system-menu"/>
        <separator/>
        <item label="Log Out">
            ...
        </item>
    </menu>
</openbox_menu>

Source


With Fedora, it slighlty different:

<?xml version="1.0" encoding="UTF-8"?>

<openbox_menu xmlns="http://openbox.org/3.4/menu">

<menu id="applications-menu" label="Applications" execute="/usr/libexec/openbox-xdg-menu applications"/>
<menu id="preferences-menu" label="Preferences" execute="/usr/libexec/openbox-xdg-menu preferences"/>
<menu id="administration-menu" label="Administration" execute="/usr/libexec/openbox-xdg-menu system-settings"/>
<menu id="terminals-menu" label="Terminals" execute="/usr/libexec/openbox-xdg-menu /etc/xdg/openbox/terminals"/>

<menu id="root-menu" label="Openbox 3">
  <separator label="Openbox"/>
  <menu id="applications-menu"/>
  <menu id="preferences-menu"/>
  <menu id="administration-menu"/>
  <separator/>
  <menu id="terminals-menu"/>
  <separator/>
  <item label="Reconfigure">
    <action name="Reconfigure" />
  </item>
  <item label="Exit">
    <action name="Exit">
      <prompt>yes</prompt>
    </action>
  </item>
  <separator/>
  <item label="Log Out">
    <action name="SessionLogout">
      <prompt>yes</prompt>
    </action>
  </item>
</menu>

</openbox_menu>

openbox Menu: Fedora default


With Debian, it is also different:

<?xml version="1.0" encoding="UTF-8"?>

<openbox_menu xmlns="http://openbox.org/"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://openbox.org/
                file:///usr/share/openbox/menu.xsd">

<menu id="root-menu" label="Openbox 3">
  <item label="Terminal emulator">
    <action name="Execute"><execute>x-terminal-emulator</execute></action>
  </item>
  <item label="Web browser">
    <action name="Execute"><execute>x-www-browser</execute></action>
  </item>
  <!-- This requires the presence of the 'openbox-menu' package to work -->
  <menu id="/Debian" />
  <separator />
  <menu id="applications-menu" label="Applications" execute="/usr/bin/obamenu"/>
  <separator />
  <item label="ObConf">
    <action name="Execute"><execute>obconf</execute></action>
  </item>
  <item label="Reconfigure">
    <action name="Reconfigure" />
  </item>
  <item label="Restart">
    <action name="Restart" />
  </item>
  <separator />
  <item label="Exit">
    <action name="Exit" />
  </item>
</menu>

</openbox_menu>

Pipe Menu

We can add sub menu in separate xml file.

    <menu id="root-menu" label="Openbox 3">
        <separator label="Static/Manual"/>
        <menu execute="cat /home/epsi/.config/openbox/menu.favorites.xml" 
            id="fav-menu" label="Favorites" icon="/usr/share/icons/gnome/16x16/categories/gnome-util.png"/>
        ...
    </menu>

I would rather create custom menu ~/.config/openbox/menu.favorites.xml, based on my favorites application.

It needs a openbox_pipe_menu tag to deliver a pipe menu

<openbox_pipe_menu>
    <item label="URxvt" icon="...">
        <action name="Execute"><execute>urxvt</execute></action>
    </item>
    ...
</openbox_pipe_menu>

The complete version is here:

<openbox_pipe_menu>
    <separator label="Terminal"/>
    <item label="URxvt" icon="/usr/share/icons/gnome/16x16/apps/utilities-terminal.png">
        <action name="Execute"><execute>urxvt</execute></action>
    </item>
    <item label="XFCE Terminal">
        <action name="Execute"><execute>xfce4-terminal</execute></action>
    </item>
    <separator label="Office"/>
    <item label="Libre Office">
        <action name="Execute"><execute>libreoffice</execute></action>
    </item>    
    <separator label="File Manager"/>
    <item label="PC Man FM Qt">
        <action name="Execute"><execute>pcmanfm-qt </execute></action>
    </item> 
    <item label="Thunar">
        <action name="Execute"><execute>thunar </execute></action>
    </item> 
    <separator label="Network"/>        
    <item label="Firefox">
        <action name="Execute"><execute>firefox</execute></action>
    </item>
    <item label="Chromium">
        <action name="Execute"><execute>chromium</execute></action>
    </item>
    <item label="Midori">
        <action name="Execute"><execute>midori</execute></action>
    </item>
    <item label="Thunderbird">
        <action name="Execute"><execute>thunderbird</execute></action>
    </item>
    <item label="Transmission">
        <action name="Execute"><execute>transmission-qt</execute></action>
    </item>
    <separator label="Media"/>
    <item label="Clementine">
        <action name="Execute"><execute>clementine</execute></action>
    </item>
    <item label="VLC">
        <action name="Execute"><execute>vlc</execute></action>
    </item>    
    <item label="Screenshot">
        <action name="Execute"><execute>lximage-qt --screenshot</execute></action>
    </item>    
    <separator label="Miscellanous"/>
    <item label="Geany">
        <action name="Execute"><execute>geany</execute></action>
    </item>
</openbox_pipe_menu>

openbox Menu: favorites

Source

Icons

You may also consider to use the nice Numix Circle icon set.

    <item label="Thunar"
        icon="/home/epsi/.local/share/icons/Numix-Circle/48/apps/thunar.svg">
        <action name="Execute"><execute>thunar </execute></action>
    </item> 

But I personally, like the plain menu, depend on my mood.

Less is more

XDG Menu

We can create xdg menu for openbox using this command:

$ xdg_menu --format openbox3 --root-menu /etc/xdg/menus/applications.menu > ~/.config/openbox/menu.xdg.xml

First prepare your ~/.config/openbox/menu.xml

    <menu id="root-menu" label="Openbox 3">
        <separator label="Static/Manual"/>
        ...
        <menu execute="cat /home/epsi/.config/openbox/menu.xdg.xml" 
            id="xdg-menu" label="XDG Menu"/>
        ...
    </menu>

Depend on your setup, the result of ~/.config/openbox/menu.xdg.xml would looks similar like this one:

<menu id="SUSE Menu" label="SUSE Menu">
 <menu id="Development" label="Development">
  ...
  <menu id="Integrated Environment" label="Integrated Environment">
       <item label="Geany">
       <action name="Execute"><execute>geany </execute></action>
     </item>
  </menu> <!-- Integrated Environment -->
  ...
 </menu> <!-- Development -->
 ...
</menu> <!-- SUSE Menu -->

We need to change a bit before we can use it as pipe menu.

<openbox_pipe_menu>
 <separator label="SUSE Menu"/>
 <menu id="Development" label="Development">
  ...
  <menu id="Integrated Environment" label="Integrated Environment">
       <item label="Geany">
       <action name="Execute"><execute>geany </execute></action>
     </item>
  </menu> <!-- Integrated Environment -->
  ...
 </menu> <!-- Development -->
 ...
</openbox_pipe_menu>

Now you can see the openSUSE’s XDG menu.

openbox Menu: XDG SUSE

Source


Merge All

You can merge the XDG menu to menu.xml as a static menu, to have a nice looking menu. You need to copy the contetn of XDG menu under id="root-menu".

<?xml version="1.0" encoding="utf-8"?>
<openbox_menu xmlns="http://openbox.org/3.4/menu">
    <menu id="system-menu" label="System">
        ...
    </menu>
    <menu id="root-menu" label="Openbox 3">
        <!-- XDG Menu -->
         <separator label="SUSE Menu"/>
         <menu id="Development" label="Development">
          ...
          <menu id="Integrated Environment" label="Integrated Environment">
               <item label="Geany">
               <action name="Execute"><execute>geany </execute></action>
             </item>
          </menu> <!-- Integrated Environment -->
          ...
         </menu> <!-- Development -->
         ...
        <!-- XDG Menu -->
        <separator label="Static/Manual"/>
        <menu execute="cat /home/epsi/.config/openbox/menu.favorites.xml" 
            id="fav-menu" label="Favorites" icon="/usr/share/icons/gnome/16x16/categories/gnome-util.png"/>
        <separator label="System"/>        
        <menu id="system-menu"/>
        <separator/>
        <item label="Log Out">
            <action name="Exit">
                <prompt>yes</prompt>
            </action>
        </item>
    </menu>
</openbox_menu>

And the final result is.

openbox Menu: Merge


Additional Menu

OB Log Out/ BL Exit

You can add oblogout or item right away.

<?xml version="1.0" encoding="utf-8"?>
<openbox_menu xmlns="http://openbox.org/3.4/menu">
    <menu id="system-menu" label="System">
        ...
        <item label="Run Command">
            <action name="gmrun"/>
        </item>
        <item label="OB Log Out">
            <action name="Execute"><execute>oblogout</execute></action>
        </item>
    </menu>
    <menu id="root-menu" label="Openbox 3">
        ..
    </menu>
</openbox_menu>

What’s Next

Consider continue reading [ Menu: Dynamic ].