Openbox

Wiki

Introduction
Screen Shots
Contributors
Platforms
Mailing Lists
Downloads
Bug Reports

Changelogs

Stable
Testing

Documentation

Whats new
Using Openbox

F.A.Q.
Openbox Features
Epist Features
Docker
The RC File
Menu File

Submitting a patch
What to do about a bug

Getting Started With Menus In Openbox

Having obtained and started openbox, the first thing that most users will want to do is create their own custom menu. (Note if you don't want to read this there is an example menu file at the bottom which you can copy and probably figure out how to edit it for your needs.) To create a custom menu create a file called menu inside your ~/.openbox directory. In this file we will create your menu. Your Menu is started with the [begin] command and ended with the [end] command. The [begin] command takes an argument in brackets which is the name of the menu. Submenus can be started with the [submenu] command which also takes the name of the submenu as an argument and is also ended with the [end] command.

A Simple Menu

So we begin with a simple menu

[begin] (OpenBox)
[submenu] (Common)
[end]
[submenu] (Browsers)
[end] #End the submenu Browsers
[end] #End the begin menu
Notice that comments are started with # and continue to the end of the line. To use this menu for the first time you will have to restart openbox, but thereafter changes that you make to this file will take effect once you save it. Note: Submenu can also take a 2nd argument (in curly brackets) which is the string positioned on top of the menu, you can see this at work in the example menu file below in the styles submenu item.

So far though our menu does not contain any commands that do any useful work, the most often used command is the [exec] command. The [exec] command takes two arguments in normal and then curly brackets. The first argument is the name of the menu entry, and the second argument is the command string to execute when this menu item is selected. For example

[exec] (Mozilla) {mozilla}
[exec] (Xterm) {xterm -fg black -bg white -sl 256}
The first will create a menu item called Mozilla, which will execute mozilla when selected, and the second will create a menu item Xterm and executes the command xterm with the given arguments. Adding these to our menu file we get
[begin] (OpenBox)
[submenu] (Common)
[exec] (Xterm) {xterm -fg black -bg white -sl 256}
[end]
[submenu] (Browsers)
[exec] (Mozilla) {mozilla}
[end] #End the submenu Browsers
[end] #End the begin menu

Other Commands

Other commands are:

  1. [workspaces] (Name)
  2. which creates a workspaces submenu
  3. [stylesdir] (filename)
  4. sets the styles directory and creates menu items for all the styles stored in that directory.
  5. [include] (filename)
  6. includes another file
  7. [config] (Name)
  8. creates a configure menu
  9. [reconfig] (Name)
  10. creates a menu item which will reload the configuration file
  11. [restart] (Name)
  12. creates a menu item that will restart openbox (not the machine)
  13. [exit] (Name)
  14. creates a menu item that will exit openbox.
With these commands in mind the default menu ends with this sequence
[submenu] (Settings)
[workspaces] (Workspace List)
[submenu] (Styles) {Choose a style...}
[stylesdir] (/usr/share/commonbox/styles)
[end]

[include] (/usr/share/commonbox/imagebgmenu)
[include] (/usr/share/commonbox/solidbgmenu)
[config] (Configure)
[reconfig] (Reload config)
[end]

[restart] (Restart)
[exit] (Exit)
[end]

Example Menu

Save the following in the file ~/.openbox/menu and then edit it for your needs.
[begin] (OpenBox)
[submenu] (Common)
[exec] (Xterm) {xterm -fg black -bg white -sl 256}
[end]
[submenu] (Browsers)
[exec] (Mozilla) {mozilla}
[end] #End the submenu Browsers
[submenu] (Settings)
[workspaces] (Workspace List)
[submenu] (Styles) {Choose a style...}
[stylesdir] (/usr/share/commonbox/styles)
[end]

[include] (/usr/share/commonbox/imagebgmenu)
[include] (/usr/share/commonbox/solidbgmenu)
[config] (Configure)
[reconfig] (Reload config)
[end]

[restart] (Restart)
[exit] (Exit)
[end]
Note: The commonbox menus mentioned in this are built by scripts in the Gentoo distribution. They will not exist on your system under any other.