Difference between revisions of "Openbox"

From ArchWiki
Jump to: navigation, search
m (System Configuration: minor correction)
(Add section for compositing)
Line 630: Line 630:
  
 
The process of creating new or modifying existing themes is covered extensively at the official [http://openbox.org/wiki/Help:Themes openbox.org] website. A user-friendly GUI to do so - {{AUR|obtheme}} - is also available from the [[AUR]].
 
The process of creating new or modifying existing themes is covered extensively at the official [http://openbox.org/wiki/Help:Themes openbox.org] website. A user-friendly GUI to do so - {{AUR|obtheme}} - is also available from the [[AUR]].
 +
 +
== Compositing effects ==
 +
{{tip|where using Openbox within an integrated desktop environment such as [[XFCE]] or [[KDE]], compositing effects will no longer be available. However, it is possible to add a compositor command (minus the ampersand - {{ic|&}} - at the end) as an autostarted application to re-enable compositing effects.}}
 +
 +
Openbox does not natively provide support for compositing, and it will therefore be necessary to install a compositor for this purpose. The use of compositing enables various desktop visual effects, including transparency, fading, and shadows. Although compositing is not a necessary component, it can help to provide a more pleasant-looking environment, and avoid common issues such as:
 +
 +
* Screen distortion when [[Openbox#Oblogout|oblogout]] is used
 +
* Visual glitches when transparency has been enabled for a terminal window (e.g. background is always visible even when overlapping other application windows; the section of background shown stays the same when moving the terminal window)
 +
 +
=== compton ===
 +
{{pkg|compton}} is a very popular choice for window managers such as Openbox due to its simplicity and reliability. As outlined in the [[compton|compton article]], it is also possible to use a custom compositing script to fine-tune the compositing effects. Once installed, to enable basic compositing without the use of shadows, add the following command to the {{ic|~/.config/openbox/autostart}} file:
 +
 +
compton -CGb &
 +
 +
=== xcompmgr ===
 +
{{pkg|xcompmgr}} is essentially an earlier - and simplier - version of Compton. Available options are outlined in the [[xcompmgr|xcompmgr article]]. Once installed, to enable basic compositing without the use of shadows, add the following command to the {{ic|~/.config/openbox/autostart}} file:
 +
 +
xcompmgr -C &
 +
 +
=== cairo-compmgr ===
 +
{{AUR|cairo-compmgr}} can provide advanced compositing effects comparable to those provided by desktop environments such as [[KDE]] (e.g. special effects when switching desktops). It also supports the use of optional plugins for various effects, and provides a user-friendly GUI for configuration. However, it is known to be more buggy than alternative compositors, and will require substantially more system resources to run than them. Available options are outlined in the [[Cairo_Compmgr|cairo compmgr article]].
 +
 +
Once installed, add the following command to the {{ic|~/.config/openbox/autostart}} file:
 +
 +
cairo-compmgr &
 +
 +
The cairo-compmgr icon will appear in the system-tray of an installed panel, from which its GUI can be opened. Alternatively, enter the following command in the terminal:
 +
 +
$ cairo-compmgr
  
 
== Mouse cursor and application icon themes ==
 
== Mouse cursor and application icon themes ==

Revision as of 15:41, 30 November 2013

Openbox is a lightweight, powerful, and highly configurable stacking window manager with extensive standards support. It may be built upon and run independently as the basis of a unique desktop environment, or within other integrated desktop environments such as KDE and XFCE, as an alternative to the window managers they provide. The LXDE desktop environment is itself built around Openbox.

A comprehensive list of features are documented at the official Openbox website. This article pertains to specifically installing Openbox under Arch Linux.

Contents

Installation

Install openbox, available in the official repositories.

Openbox Sessions

Again, Openbox may be run independently as a standalone window manager, or within other integrated desktop environments such as KDE and XFCE as an alternative to the window managers they provide.

Standalone

Many popular display managers such as LXDM, SLiM, and LightDM will automatically detect Openbox, allowing for it to be run as a standalone session.

However, it may be necessary to manually specify the command to start an openbox session where intending to set it as a default session for SLiM, or where not using a display manager at all (e.g. logging in at the command line, followed by the command startx). In either instance, it will be necessary to modify the Xinitrc file in order to add the following command:

exec openbox-session

Within other desktop environments

To replace the native window manager provided by an integrated desktop environment, use the following command within a session:

$ openbox --replace

To restore the native window manager, first cancel the command by pressing CTRL and c. The syntax of the command to then restore the native window manager is:

$ <name of native window manager> --replace

For example the command to restore the native window manager used by XFCE is:

$ xfwm4 --replace

Gnome 3

Openbox does not seem to work with Gnome 3. The Gnome-Shell touch-style interface requires both its native window manager - mutter - and the native gtk-window-decorator package to function. Furthermore, attempting to run Openbox within the Classic-Gnome-Shell interface results in the loss of the gnome-panel. Ceasing Openbox and attempting to restore the native window manager will result in crashing the desktop. Gnome 3 is tightly integrated, and is therefore deliberately designed not to be modular in nature (i.e. allowing components to be changed).

XFCE

Tip: The native window manager for XFCE is xfwm4.

Overall, Openbox works well in XFCE, although it will not be possible to use the native XFCE workspace switcher to add or remove virtual desktops; this will have to be undertaken using obconf. There are two methods available to ensure Openbox is automatically used by default as the window manager.

The first is to simply save the session. The Save session for future logins option is available in the logout... dialog box. However, this will also mean any application windows open while exiting the session will be restored when starting a new one as well. It is also important to note that where restoring xfwm4 during a session, the Save session for future logins option will have to be enabled on that occasion to make this change permanent. Not doing so may result in Openbox being restored again, as the previous saved session may be loaded instead. However, once xfwm4 has been restored, from the next session onwards there will no longer be any need to save future sessions.

The recommended alternative is to autostart Openbox for each session. To do so, from the main menu, first select settings, and then session and startup. Once the application window opens, select the Application Autostart tab to show all autostarted applications and programs, and click the Add button to bring up the Add Application window. The following details can be entered for each field:

  • Name: openbox-wm
  • Description: openbox-wm
  • Command: openbox --replace

Once complete, click OK, ensure that the checkbox next to the openbox-wm entry is ticked, and then restart the session for the change to take place. The benefit of this method is that autostarted applications can be easily enabled and disabled at will via their autostart checkboxes. Consequently, to allow the native window manager - xfwm4 - to take back over, just clear the openbox-wm tickbox and restart the session.

KDE

Tip: The native window manager for KDE is kwin.

Openbox works very well in KDE, combined with a noticable improvement in performance and responsiveness. By default, a KDE/Openbox session will be made automatically available upon installing openbox, even if the KDE environment itself has not been installed. Most popular display managers will therefore allow KDE with Openbox as the window manager to be selected as a session.

To manually start KDE with Openbox as the window manager - again, as a default session for SLiM, or where not using a display manager at all - add the following command to the Xinitrc file:

exec openbox-kde-session

System Configuration

Those installing Openbox - particularly as a stand-alone Window Manager - will have noticed that several elements may fail to work properly, or even work at all. Examples of the common problems encountered are:

  • File Managers: Other partitions are not displayed or accessable. The trash function - where provided - does not work
  • Authentication: Passwords are not stored / remembered during sessions
  • Secure Shell (SSH): SSH agent will not start
  • Wireless Connection: Instant failure when attempting to connect to wifi (related to authentication)
  • Themes: Application windows are mismatched or haphazard-looking
  • Folders: Expected folders such as Documents, Downloads and so forth are missing from the Home folder
  • System Tray: Installed packages fail to autostart or can be seen running twice

Most of these problems are actually the result of Dbus and GTK issues, both of which can be fixed simultaneously by editing the ~/.xprofile file - or if using SLiM as a display manager instead - by editing the ~/.xinitrc file. It will also be necessary to install some key packages to ensure full functionality.

DBUS

The file manager, authentication, SSH agent, and wifi-connection problems will likely be due to the D-Bus Communication System not functioning correctly. Where using SLiM it will be necessary to edit the ~/.xinitrc file. Where using another display manager such as LXDM, it will be necessary to edit ~/.xprofile instead.

Once the correct configuration file has been opened (both are executables), add the following command:

if which dbus-launch >/dev/null && test -z "$DBUS_SESSION_BUS_ADDRESS"; then
    eval "$(dbus-launch --sh-syntax --exit-with-session)"
fi

GTK 2

Problems with the theme and look will likely be due to the absence of the appropriate command to ensure that a uniform look must be applied to applications that use GTK 2. Again, edit ~/.xinitrc and/or ~/.xprofile with the following command:

export GTK2_RC_FILES="$HOME/.gtkrc-2.0" 

The ~/.gtkrc-2.0 file will be automatically generated where using lxappearance to set themes.

It will also be necessary to install libgnomeui to ensure that Qt is also able to find GTK themes.

XDG

In addition to sourcing the local ~/.config/openbox/autostart file to autostart applications, Openbox will also source .desktop files automatically installed by some packages in the global /etc/xdg/autostart directory. The package responsible for allowing Openbox to additionally source the /etc/xdg/autostart directory is python2-xdg.

For example, where initially autostarting a package such as the Network Manager applet (nm-applet) locally, should python2-xdg be installed at a later time - either explicitly or as a dependency for another package - its global XDG .desktop file will then also be sourced as a consequence, resulting in seeing two icons running in the system tray. It is therefore recommended to install python2-xdg explicitly, as this will ensure that applications that should automatically autostart when installed will do so.

Home folders

Tip: This fix will be especially helpful for those who wish to use a file manager to manage their desktop, as it will automatically create a special ~/Desktop directory, which will house all files and application shortcuts stored on the desktop itself.

Where expected Home folders such as Downloads, Documents, etc., are not present, then it will be necessary to install Xdg user directories (xdg-user-dirs). Once installed, run the following command without the use of the sudo or gksu prefix:

$ xdg-user-dirs-update

Authentication and Passwords

For authentication (e.g. WiFi passwords, etc.), it will be necessary to install the appropriate packages. They are:

Openbox Configuration

Warning: Do not edit the files listed below as Root.
Tip: Local configuration files will always override global equivalents. These files may also be manually edited by any appropriate text editor, such as Leafpad or Geany; there is no need to use sudo or gksu commands to edit them.

Four key files form the basis of the openbox configuration, each serving a unique role. They are: rc.xml, menu.xml, autostart, and environment. Although these files are discussed in more detail below, to start configuring Openbox, it will first be necessary to create a local Openbox profile (i.e for your specific user account) based on them. This can be done by copying them from the global /etc/xdg/openbox profile (applicable to any and all users) as a template:

$ mkdir -p ~/.config/openbox
$ cp -R /etc/xdg/openbox/* ~/.config/openbox

Once copied, it will then be necessary to change the permissions of the new files from root to that of the local account. The syntax of the command to do so is:

$ sudo chown -R <user name> ~/.config/openbox

rc.xml

Tip: Custom keyboard shortcuts (keybindings) must be added to the <keyboard> section of this file, and underneath the <!-- Keybindings for running aplications --> heading.

~/.config/openbox/rc.xml is the main configuration file, responsible for determining the behaviour and settings of the overall session, including:

  • Keyboard shortcuts (e.g. starting applications; controlling the volume)
  • Theming
  • Desktop and Virtual desktop settings, and
  • Application Window settings

This file is also pre-configured, meaning that it will only be necessary to amend existing content in order to customise behaviour to suit personal preference.

menu.xml

~/.config/openbox/menu.xml defines the type and behaviour of the desktop menu, accessable by right-clicking the background. Although the default provided is a static menu (meaning that it will not automatically update when new applications are installed), it is possible to employ the use of dynamic menus that will automatically update as well.

The available options are discussed extensively below in the Menus section.

autostart

Tip: Again, be aware that some applications will automatically start via .desktop files installed in the /etc/xdg/autostart directory. Where using - or having previously used - another desktop environment such as XFCE, then it is also possible that .desktop files may be present in the ~/.config/autostart/ directory.

~/.config/openbox/autostart determines which applications are to be launched upon beginning the Openbox session. These may include:

  • Panels and/or docks
  • Compositors
  • Background providers
  • Screensavers
  • Applications to autoload or autostart (e.g. Conky)
  • Daemon processes (e.g. File Managers for automounting and other functions)
  • Other appropriate commands (e.g. disable DPMS)

Listing commands

There are two very important points to note when adding commands to the ~/.config/openbox/autostart file:

  • Each and every command must be terminated with an ampersand (&). Where a command does not end with an ampersand, then no further commands listed below it will be executed.
  • It is strongly recommended to add delays to the execution of some or all commands in the autostart file, even if only by a single second. The consequence of not doing so is that all commands will be executed simultaneously, potentially resulting in the mis- or non-starting of items. The syntax of the command to delay the execution of commands (in seconds) is:
(sleep <number of seconds>s && <command>) &

For example, to delay the execution of Conky by 3 seconds, the command would be (and note the termination of it with an ampersand):

(sleep 3s && conky) &

Here is a more complete example of a possible ~/.config/openbox/autostart file:

## Autostart File ##

##Disable DPMS
xset -dpms; xset s off &

##Compositor
compton -CGb &

##Background
(sleep 1s && nitrogen --restore) &

##tint2 panel
(sleep 1s && tint2) &

##Sound Icon
(sleep 1s && volumeicon) &

##Screensaver
(sleep 1s && xscreensaver -no-splash) &

##Conky
(sleep 3s && conky) &

##Disable touchpad
/user/bin/synclient TouchpadOff=1 &

environment

Note: This is the least important file, and many users may not need to edit it at all.

~/.config/openbox/environment can be used to export and set relevant environmental variables such as to:

  • Define new pathways (e.g. execute commands that would otherwise require the entire pathway to be listed with them)
  • Change language settings, and
  • Define other variables to be used (e.g. the fix for GTK theming could be listed here)

Optional GUI configuration packages

Several GUIs are available to quickly and easily configure your Openbox desktop. From the official repositories these include:

  • obconf: Basic Openbox configuration manager
  • lxappearance-obconf: LXDE configuration manager (provides additional options)
  • lxinput: LXDE keyboard and mouse configuration
  • lxrandr: LXDE monitor configuration

Others, such as obkeyAUR (configure keyboard shortcuts via the rc.xml file) and ob-autostartAUR (configure the Openbox autostart file) are available from the AUR. Programs and applications relating to the configuration of Openbox's desktop menu are discussed in the Menus section.

Openbox Reconfiguration

Tip: where not already present, it would be worthwhile adding this command to a menu and/or as a keybind for convenience.

Openbox will not always automatically reflect any changes made to its configuration files within a session. As a consequence, it will be necessary to manually reload those files after they have been edited. To do so, enter the following command:

$ openbox --reconfigure

Where intending to add this command as a keybind to ~/.config/openbox/rc.xml, it will only be necessary to list the command as reconfigure. An example has been provided below, using the Super+F11 keybind:

<keybind key="W-F11">
  <action name="Reconfigure"/>
</keybind>

Keybinds

All keybinds must be added to the ~/.config/openbox/rc.xml file, and below the <!-- Keybindings for running aplications --> heading. Although a brief overview has been provided here, a more in-depth explanation of keybindings can be found at openbox.org.

Special keys

While the use of standard alpha-numeric keys for keybindings is self-explanatory, special names are assigned to other types of keys, such as modifers, multimedia keys and navigation keys.

Modifiers

Modifer keys play an important role in keybindings (e.g. holding down the shift or CTRL / control key in combination with another key to undertake an action). Using modifers helps to prevent conflicting keybinds, whereby two or more actions are linked to the same key or combination of keys. The syntax to use a modifer with another key is:

"<modifier>-<key>"

The modifer codes are as follows:

  • S: Shift
  • C: Control / CTRL
  • A: Alt
  • W: Super / Windows
  • M: Meta
  • H: Hyper (If it is bound to something)

For example, the code below would use super and t to launch lxterminal

<keybind key="W-t">
    <action name="Execute">
        <command>lxterminal</command>
    </action>
</keybind>

Multimedia keys

Where available, it is possible to set the appropriate multimedia keys to perform their intended functions, such as to control the volume and/or the screen brightness. These will usually be integrated into the function keys, and are identified by their appropriate symbols. See the Multimedia Keys article for further information.

The volume and brightness multimedia codes are as follows (note that commands will still have to be assigned to them to actually function):

  • XF86AudioRaiseVolume: Increase volume
  • XF86AudioLowerVolume: Decrease volume
  • XF86AudioMute: Mute / unmute volume
  • XF86MonBrightnessUp: Increase screen brightess
  • XF86MonBrightnessDown: Decrease screen brightness

Examples of how these may be used in ~/.config/openbox/rc.xml have been provided below.

Navigation keys

These are the directional / arrow keys, usually used to move the cursor up, down, left, or right. The (self-explanatory) navigation codes are as follows:

  • Up: Up
  • Down: Down
  • Left: Left
  • Right: Right

Volume Control

What commands should be used for controlling the volume will depend on whether ALSA, PulseAudio, or OSS is used for sound.

ALSA

If ALSA is used for sound, the amixer program can be used to adjust the volume, which is part of the alsa-utils package. The following example - using the multimedia keys intended to control the volume - will adjust the volume by +/- 5% (which may be changed, as desired):

<keybind key="XF86AudioRaiseVolume">
    <action name="Execute">
        <command>amixer set Master 5%+ unmute</command>
    </action>
</keybind>
<keybind key="XF86AudioLowerVolume">
    <action name="Execute">
        <command>amixer set Master 5%- unmute</command>
    </action>
</keybind>
<keybind key="XF86AudioMute">
    <action name="Execute">
        <command>amixer set Master toggle</command>
    </action>
</keybind>

Pulseaudio

Where using PulseAudio with ALSA as a backend, the amixer program commands will have to be modifed, as illustrated below in comparison to the ALSA example:

<keybind key="XF86AudioRaiseVolume">
    <action name="Execute">
        <command>amixer -D pulse set Master 5%+ unmute</command>
    </action>
</keybind>
<keybind key="XF86AudioLowerVolume">
    <action name="Execute">
        <command>amixer -D pulse set Master 5%- unmute</command>
    </action>
</keybind>
<keybind key="XF86AudioMute">
    <action name="Execute">
        <command>amixer set Master toggle</command>
    </action>
</keybind>

OSS

Note: This option may be suitable for more experienced users.

Where using OSS, it is possible to create keybindings to raise or lower specific mixers. This allows, for example, the volume of a specific application (such as an audio player) to be changed without changing the overall system volume settings in turn. In this instance, the application must first have been configured to use its own mixer.

In the following example, MPD has been configured to use its own mixer - also named mpd - to increase and decrease the volume by a single decibel at a time. The -- that appears after the ossmix command has been added to prevent a negative value from being treated as an argument:

<keybind key="[chosen keybind]">
    <action name="Execute">
        <command>ossmix -- mpd +1</command>
    </action>
</keybind>
<keybind key="[chosen keybind]">
    <action name="Execute">
        <command>ossmix -- mpd -1</command>
    </action>
</keybind>

Brightness control

The xbacklight program is used to control screen brightness, which is part of the Xorg X-Window system. In the example below, the multimedia keys intended to control the screen brightness will adjust the settings by +/- 10%:

<keybind key="XF86MonBrightnessUp">
     <action name="Execute">
       <command>xbacklight +10</command>
     </action>
</keybind>
<keybind key="XF86MonBrightnessDown">
     <action name="Execute">
       <command>xbacklight -10</command>
     </action>
</keybind>

Window Snapping

Many desktop environments and window managers support window snapping (e.g. Windows 7 Aero snap), whereby they will automatically snap into place when moved to the edge of the screen. This effect can also be simulated in Openbox through the use of keybinds on focused windows.

As illustrated in the example below, percentages must be used to determine window sizes (see openbox.org for further information). In this instance, The super key is used in conjunction with the navigation keys:

<keybind key="W-Left">
    <action name="UnmaximizeFull"/>
    <action name="MaximizeVert"/>
    <action name="MoveResizeTo">
        <width>50%</width>
    </action>
    <action name="MoveToEdge"><direction>west</direction></action>
</keybind>
<keybind key="W-Right">
    <action name="UnmaximizeFull"/>
    <action name="MaximizeVert"/>
    <action name="MoveResizeTo">
        <width>50%</width>
    </action>
    <action name="MoveToEdge"><direction>east</direction></action>
</keybind>

However, it should be noted that once a window has been 'snapped' to an edge, it will remain vertically maximised unless subsequently maximised and then restored. The solution is to implement additional keybinds - in this instance using the down and up keys - to do so. This will also make pulling 'snapped' windows from screen edges faster as well:

<keybind key="W-Down">
   <action name="Unmaximize"/>
</keybind>
<keybind key="W-Up">
   <action name="Maximize"/>
</keybind>

This Ubuntu forum thread provides more information. Applications such as opensnap-git are also available from the AUR to automatically simulate window snapping behaviour without the use of keybinds.

Desktop Menu

It is also possible to create a keybind to access the desktop menu. For example, the following code will bring up the menu by pressing CTRL + m:

<keybind key="C-m">
    <action name="ShowMenu">
       <menu>root-menu</menu>
    </action>
</keybind>

Menus

It is possible to employ three types of menu in Openbox: static, pipes (dynamic), and generators (static or dynamic). They may also be used alone or in any combination.

Static

As the name would suggest, this default type of menu does not change in any way, and may be manually edited and/or (re)generated automatically through the use on an appropriate software package.

Fast and efficient, while this type of menu can be used to select applications, it can also be useful to access specific functions and/or perform specific tasks (e.g. desktop configuration), leaving the access of applications to another process (e.g. the synapse or xfce4-appfinder applications).

The ~/.config/openbox/menu.xml file will be the sole source of static desktop menu content.

menumaker

Warning: A root terminal must be installed in order to use MenuMaker, even though a standard user terminal may be used to run it. xterm is a good choice.

menumaker automatically generates xml menus for several window managers, including Openbox, Fluxbox, IceWM and XFCE. It will search for all installed executable programs and consequently create a menu file for them. It is also possible to configure MenuMaker to exclude certain application types (e.g. relating to Gnome or KDE), if desired.

Once installed and executed, it will automatically generate a new ~/.config/openbox/menu.xml file. To avoid overwriting an existing file, enter:

$ mmaker -v OpenBox3

Otherwise, to overwrite an existing file, add the force argument (f):

$ mmaker -vf OpenBox3

For a full description of available options, enter:

$ mmaker --help 

Once a new ~/.config/openbox/menu.xml file has been generated it may then be manually edited, or configured using a GUI menu editor, such as obmenu.

obmenu

Warning: obm-xdg - a pipe menu to generate a list of GTK and Gnome applications - is also provided with obmenu. However, it has long-running bugs whereby it may produce an invalid output, or even not function at all. Consequently it has been omitted from discussion.

obmenu is a user-friendly GUI application to edit ~/.config/openbox/menu.xml, without the need to code in xml.

xdg-menu

archlinux-xdg-menu will automatically generate a menu based on xdg files contained within the /etc/xdg/ directory for numerous Window Managers, including Openbox. Review the Xdg-menu#OpenBox article for further information.

Pipes

Tip: It is entirely feasible for a static menu to contain one or more pipe sub-menus. The functionality of some pipe menus may also rely on the installation of relevant software packages.

This type of menu is in essence a script that provides dynamic, refreshed lists on-the-fly as and when run. These lists may be used for multiple purposes, including to list applications, to provide information, and to provide control functions. Some examples of pipe menus that may be used include:

  • Listing previously accessed files or directories
  • System information (e.g. the current use of resources)
  • Weather reports, and
  • Application control (e.g. media players).

Pre-configured pipe menus can be installed, although not from the official repositories. More experienced users can also modify and/or create their own custom scripts. Again, ~/.config/openbox/menu.xml may and commonly will contain several pipe menus.

Examples

Openbox.org also provides a further list of pipe menus.

Generators

This type of menu is akin to those provided by the taskbars of desktop environments such as XFCE or LXDE. Automatically updating on-the-fly, this type of menu can be powerful and very convenient. It may also be possible to add custom categories and menu entries; read the documentation for your intended dynamic menu to determine if and how this can be done. The downside of utilising this type of menu is that it:

  • Will likely be focused primarily or even entirely on installed applications
  • Is the "slowest" type of menu
  • Will hide its internal processes like any other application (i.e. loss of user control)
  • May still have to be edited - where permitted - by those wishing to add extra functionality (e.g. access to key system files).

A menu generator will have to be executed from the ~/.config/openbox/menu.xml file.

obmenu-generator

Tip: icons can still be disabled in obmenu-generatorAUR, even where enabled in ~/.config/openbox/rc.xml.

obmenu-generatorAUR is currently only available from the AUR, although it is still highly recommended. With the ability to be used as a static or dynamic menu, it is highly configurable, powerful, and versatile. Menu categories and individual entries may also be easily hidden, customised, and/or added with ease. The official homepage provides further information and screenshots.

Below is an example of how obmenu-generator would be dynamically executed without icons in ~/.config/openbox/menu.xml:

<?xml version="1.0" encoding="utf-8"?>
<openbox_menu>
    <menu id="root-menu" label="OpenBox 3" execute="/usr/bin/obmenu-generator -p">
    </menu>
</openbox_menu>

To automatically iconify entries, the -i option would be added:

<menu id="root-menu" label="OpenBox 3" execute="/usr/bin/obmenu-generator -i -p">

openbox-menu

Tip: If this menu produces an error, it may be solved by enabling icons in ~/.config/openbox/rc.xml.

openbox-menu uses the LXDE menu-cache to create dynamic menus. The official homepage provides further information and screenshots.

obmenugen

ObmenugenAUR is currently only available from the AUR, and can be used to a generate static or dynamic application menu based on .desktop files. The official homepage provides further information.

Menu icons

To show icons next to menu entries, it will be necessary to ensure they are enabled in the <menu> section of the ~/.config/openbox/rc.xml file:

<applicationIcons>yes</applicationIcons>

Where using a static menu, it will then be necessary to edit the ~/.config/openbox/menu.xml file to provide both the icon = command, along with the full path and icon name for each entry. An example of the syntax used to provide an icon for a category is:

<menu id="apps-menu" label="[label name]" icon="[pathway to icon]/[icon name]">

Desktop menu as a panel menu

Tip: XDoTool can simulate any keybind for any action, and as such, it may therefore be used for many other purposes...

xdotool is a package that can issue commands to simulate key presses / keybinds, meaning that it is possible to use it to invoke keybind-related actions without having to actually press their assigned keys. As this includes the ability to invoke an assigned keybind for the Openbox desktop menu, it is therefore possible to use XDoTool to turn the Openbox desktop menu into a panel menu. Especially where the desktop menu is heavily customised and feature-rich, this may prove very useful to:

  • Replace an existing panel menu
  • Implement a panel menu where otherwise not provided or possible (e.g. for tint2-svnAUR or a rox panel)
  • Compensate where losing access to the desktop menu due to the use of Rox or xfdesktop to manage the desktop.

Once XDoTool has been installed - if not already present - it will be necessary to create a keybind to access the root menu in ~/.config/openbox/rc.xml, and again below the <!-- Keybindings for running aplications --> heading. For example, the following code will bring up the menu by pressing CTRL + m:

<keybind key="C-m">
    <action name="ShowMenu">
       <menu>root-menu</menu>
    </action>
</keybind>

Openbox must then be re-configured with the following command:

$ openbox --reconfigure

In this instance, XDoTool will be used to simulate the CTRL + m keypress to access the desktop menu with the following command (note the use of + in place of -):

xdotool key control+m

How this command may be used as a panel launcher / icon is largely dependent on the features of panel used. While some panels will allow the above command to be executed directly in the process of creating a new launcher, others may require the use of an executable script. As an example, a custom executable script called obpanelmenu.sh will be created in the Home folder, using the Leafpad text editor:

leafpad ~/obpanelmenu.sh

Once the empty file has been opened, the appropriate XDoTool command must be added to the empty file (i.e. to simulate the CTRL + m keypress for this example):

xdotool key control+m

After the file has been saved and closed, it may then be made into an executable script with the following command:

chmod +x ~/obpanelmenu.sh

Executing it will bring up the Openbox desktop menu. Consequently, where using a panel that supports drag-and-drop functionality to add new launchers (e.g. the Rox panel, simply drag the executable script onto it before changing the icon to suit personal taste. For instructions on how to use this executable script with tint2-svnAUR - a derivative of the popular tint2 panel that allows launchers to be added - see Tint2-Svn launchers.

GTK Desktop Theming

Tip: It is strongly advised to install the obconf and lxappearance-obconf GUI applications to configure visual settings and theming. The latter is particularly important as it is responsible for generating the ~/.gtkrc-2.0 file (see the GTK fix section).

It is important to note that a substantial range of both Openbox-specific and generalised, Openbox-compatible GTK themes are available to change the look of window decorations and the desktop menu. Generalised themes are designed to be simultaneously compatible with a range of popular desktop environments and/or window managers, commonly including Openbox. For example, gtk-theme-numix-blueAUR supports both Openbox and XFCE.

It is therefore recommended to check the description - not just the name - of a desired theme to determine if it is at least compatible with Openbox. Where this is not the case, then check if an Openbox-compatible derivative of it is available, usually found in the AUR.

Configuration

obconf and/or lxappearance-obconf should be used to select and configure available themes.

Alternatively, theme selection can be undertaken manually by editing ~/.config/openbox/rc.xml, and amending the <name> key in the <theme> section. In this instance, it will then be necessary to edit the ~/.gtkrc-2.0 file as well, and amend the gtk-theme= command, prior to reconfiguring Openbox to implement the changes made.

Installation: Official and AUR

A good selection of openbox-themes are available from the official repositories.

Both Openbox-specific and Openbox-compatible themes installed from the official repositories and/or the AUR will be automatically installed to the /usr/share/themes directory. Both will also be immediately available for selection.

Installation: Other Sources

box-look.org is an excellent and well-established source of themes. deviantART.com is another excellent resource. Many more can be found through the utilisation of a search engine.

Zip and tar files

Themes downloaded from other sources such as box-look.org will usually be compressed in a .tar.gz or .zip format. Although tar will have been installed as part of the base arch installation to extract .tar.gz files, it will be necessary to install a program such as unzip to extract .zip files in the terminal. user-friendly GUI archivers are also available; see List_of_Applications#Compression_tools for further information.

Extracted theme files should also be placed in the /usr/share/themes directory. For example, assuming downloaded content is automatically stored in the ~/Downloads folder, to simultaneously extract and move a .tar.gz theme file, the syntax of the command would be:

$ sudo tar xvf ~/Downloads/<theme file name>.tar.gz -C /usr/share/themes/

To use unzip in the same scenario for a .zip theme file, the syntax of the command would be:

$ sudo unzip ~/Downloads/<theme file name>.zip -d /usr/share/themes/

Alternatively, it is also possible to simply move / copy and paste the extracted files to the /usr/share/themes directory using an installed file manager as root. The syntax to do so is:

$ gksu <name of file manager>

Troubleshooting

There are two particular problems that may be encountered on rare occasions, especially where downloading themes from unsupported websites. These have been addressed below.

Theme cannot be used

If for any reason the newly extracted theme cannot be selected, open the theme directory to first ensure that it is indeed compatible with Openbox by determining that:

  • An openbox-3 directory is present, and that within this directory
  • a themerc file is also present.
  • An .obt (OpenBox Theme) file may also be present in some instances. An .obt file can then be manually loaded using obconf, whereby it should instantly appear for selection.

Where expected files and directories are present and correct, then on occasion it is possible that the theme author has not correctly set permission to access the file (e.g. permission may still be for the account of the author, rather than for root). To at least eliminate this possibility, enter the following command:

$ sudo chown -R root /user/share/themes

Theme looks broken

Of course, the first line of enquiry would be to check that it is not just a badly made, broken theme! Otherwise, ensure that the Openbox GTK fix has been implemented, and then re-start the session.

Unfortunately some older themes can simply break if not maintained sufficiently to keep pace with the changes incurred by GTK updates. To avoid such occurrences, it is best to check that desired themes have recently been created or at least updated / patched. Otherwise it will be necessary to remove the theme altogether.

Edit or create new themes

Tip: Where deciding to modify an existing theme (e.g. the colour scheme), it would be best to work on a copy of it, rather than the original. This will retain the original should anything go wrong, and ensure that your changes are not over-written through an update.

The process of creating new or modifying existing themes is covered extensively at the official openbox.org website. A user-friendly GUI to do so - obthemeAUR - is also available from the AUR.

Compositing effects

Tip: where using Openbox within an integrated desktop environment such as XFCE or KDE, compositing effects will no longer be available. However, it is possible to add a compositor command (minus the ampersand - & - at the end) as an autostarted application to re-enable compositing effects.

Openbox does not natively provide support for compositing, and it will therefore be necessary to install a compositor for this purpose. The use of compositing enables various desktop visual effects, including transparency, fading, and shadows. Although compositing is not a necessary component, it can help to provide a more pleasant-looking environment, and avoid common issues such as:

  • Screen distortion when oblogout is used
  • Visual glitches when transparency has been enabled for a terminal window (e.g. background is always visible even when overlapping other application windows; the section of background shown stays the same when moving the terminal window)

compton

compton is a very popular choice for window managers such as Openbox due to its simplicity and reliability. As outlined in the compton article, it is also possible to use a custom compositing script to fine-tune the compositing effects. Once installed, to enable basic compositing without the use of shadows, add the following command to the ~/.config/openbox/autostart file:

compton -CGb &

xcompmgr

xcompmgr is essentially an earlier - and simplier - version of Compton. Available options are outlined in the xcompmgr article. Once installed, to enable basic compositing without the use of shadows, add the following command to the ~/.config/openbox/autostart file:

xcompmgr -C &

cairo-compmgr

cairo-compmgrAUR can provide advanced compositing effects comparable to those provided by desktop environments such as KDE (e.g. special effects when switching desktops). It also supports the use of optional plugins for various effects, and provides a user-friendly GUI for configuration. However, it is known to be more buggy than alternative compositors, and will require substantially more system resources to run than them. Available options are outlined in the cairo compmgr article.

Once installed, add the following command to the ~/.config/openbox/autostart file:

cairo-compmgr &

The cairo-compmgr icon will appear in the system-tray of an installed panel, from which its GUI can be opened. Alternatively, enter the following command in the terminal:

$ cairo-compmgr

Mouse cursor and application icon themes

Any mouse cursor and/or application icon theme may be used with Openbox. Numerous themes are available from both the official repositories and the AUR.

xcursor themes (mouse)

Tip: Review the Xcursor article for an in-depth explanation.

Standard xcursor theme packages available from the official repositories include xcursor-themes, xcursor-bluecurve, xcursor-vanilla-dmz, and xcursor-pinux. To search the official repositories for all available xcursor themes, enter the following command:

$ pacman -Ss xcursor

Installed x-cursor themes may then be set though using the obconf and lxappearance-obconf GUI applications. It may then be necessary to either log out and back in again to implement the change, or to reconfigure Openbox.

Application icon themes

Standard xcursor theme packages available from the official repositories include the gnome-icon-theme and lxde-icon-theme. A nice icon theme currently available from the AUR is numix-icon-theme-gitAUR. To search the official repositories for all available icon themes, enter the following command:

$ pacman -Ss icon-theme

Again, installed icon themes may then be set though using the obconf and lxappearance-obconf GUI applications. It may then be necessary to either log out and back in again to implement the change, or to reconfigure Openbox.

Desktop Icons and Wallpapers

Openbox does not natively support the use of desktop icons or wallpapers. As a consequence, it will be necessary to install additional applications for this purpose, where desired.

Desktop management using file managers

Some file managers have the capacity to fully manage the desktop, meaning that they may be used to provide wallpapers and enable the use if icons on the desktop. The LXDE desktop environment itself uses PCManFM for this purpose.

PCManFM

Tip: Add the pcmanfm --desktop-pref command to the desktop menu for easy access.

Where using pcmanfm to manage the desktop, it will be necessary to edit the ~/.config/openbox/autostart file in order to autostart either in desktop mode:

pcmanfm --desktop &

Once a new session has started, the original desktop menu will be replaced with one provided by the chosen file manager. However, before restoring the Openbox desktop menu, first select desktop preferences to set the desktop wallpaper. The original desktop menu may then be resored by enabling the show menus provided by the window manager when desktop is clicked option in the Advanced tab. To access the desktop preferences window in future, the command is:

pcmanfm --desktop-pref

User content such as text files, documents, images and so forth can be dragged and dropped onto the desktop from the file manager. To create shortcuts for applications it will be necessary to copy their .desktop files to the desktop itself; do not drag and drop them there, as they will be moved completely. The syntax of the command to do so is:

cp /usr/share/applications/<name of application>.desktop ~/Desktop

For example - where installed - to create a desktop shortcut for lxterminal, the following command would be used:

cp /usr/share/applications/lxterminal.desktop ~/Desktop

For those who used xdg-user-dirs to create their home directories no further configuration will be required.

SpaceFM

Tip: Add the spacefm --desktop-pref command to the desktop menu for easy access.

Where using spacefm to manage the desktop, it will be necessary to edit the ~/.config/openbox/autostart file in order to autostart either in desktop mode:

spacefm --desktop &

Once a new session has started, the original desktop menu will be replaced with one provided by the chosen file manager. However, before restoring the Openbox desktop menu, first select desktop settings to set the desktop wallpaper. The original desktop menu may then be resored by enabling the Right click shows WM menu option in the Desktop tab. To access the desktop settings window in future, the command is:

spacefm --desktop-pref

User content such as text files, documents, images and so forth can be dragged and dropped onto the desktop from the file manager. To create shortcuts for applications it will be necessary to copy their .desktop files to the desktop itself; do not drag and drop them there, as they will be moved completely. The syntax of the command to do so is:

cp /usr/share/applications/<name of application>.desktop ~/Desktop

For example - where installed - to create a desktop shortcut for lxterminal, the following command would be used:

cp /usr/share/applications/lxterminal.desktop ~/Desktop

For those who used xdg-user-dirs to create their home directories no further configuration will be required.

Rox

Note: It may take quite a lot of time - and reading - to properly configure Rox to suit personal preference. See the official website for more information; substantial documentation is also provided with Rox.

rox is a very simple yet very powerful file manager that may be used to set background wallpapers, enable icons on the screen, and/or even provide a panel to access folders and launch applications.

However, where Rox is used to manage the desktop, the Openbox desktop menu will no longer be accessible, although applications may still be started from a Rox-panel by selecting Home, and then applications. It is also possible to use the desktop menu as a panel menu, by dragging and dropping the executable file created onto it (and selecting a new icon for it, perhaps from usr/share/icons). To use rox to set the wallpaper, enable icons, and optionally provide a panel, add the following command to the ~/.config/openbox/autostart file:

rox --rox-session &

Alternatively, to use Rox to provide a panel only (and keep the Openbox desktop menu), add one of the following commands instead:

rox --top=PANEL &
rox --bottom=PANEL &
rox --left=PANEL &
rox --right=PANEL &

To initally enable the ability to logout, reboot, restart (etc.) without having to enter commands in the terminal, then a panel icon can be created for oblogout. Simply use Rox to navigate to /usr/bin and then drag the oblogout executable onto the panel.

Wallpaper / background programs

Tip: The wallpaper programs listed here will have many more options than shown in this brief overview, including the ability to use solid colours for backgrounds. Review their documentation and man pages for more information.

There are numerous packages available to set desktop backgrounds in Openbox, each of which will need to be autostarted in the ~/.config/openbox/autostart file. A few of the most well known have been listed.

nitrogen

Tip: If nitrogen does not show in the desktop menu, then it can be manually added.

nitrogen is a user-friendly choice, as it also provides a GUI window to browse and set installed images. To access the GUI, enter the following command in a terminal:

$ nitrogen

To use nitrogen as the background provider, add the following command to the ~/.config/openbox/autostart file so that it will restore the last set wallpaper:

nitrogen --restore &

feh

Feh is a popular image viewer that may also be used to set wallpapers. In this instance, it will be necessary to add the full directory path and name of the image to be used as the wallpaper. To use Feh as the background provider, add the following command to the ~/.config/openbox/autostart file:

feh --bg-scale </path/to/image.file> &

hestroot

hsetroot is a command-line tool specifically designed to set wallpapers. As with Feh, it will be necessary to add the full directory path and name of the image to be used as the wallpaper. To use HSetRoot as the background provider, add the following command to the ~/.config/openbox/autostart file:

hsertroot -fill </path/to/image.file> &

xsetroot

xsetroot is installed as part of the Xorg X-Windows system, and may be used to set simple background colours. For example, to use XSetRoot to set a black background, the following would be added to the ~/.config/openbox/autostart file:

xsetroot -solid "#000000" &

Icon programs

While there are programs dedicated to enabling desktop icons alone, it would seem that they have greater drawbacks than the utilisation of file managers for the task. These programs are discussed briefly, below.

idesk

idesk is a simple program that can enable icons in addition to managing wallpaper. It will be necessary to create an ~/.idesktop directory, and desktop icons must also be manually created. To use idesk to provide icons, add the following command to the ~/.config/openbox/autostart file:

idesk &

xfdesktop

xfdesktop is the desktop manager for XFCE. The Thunar file manager will also be downloaded as a dependency. Where this is used, the Openbox desktop menu will no longer be accessible by right-clicking the background.

As such, it will consequently be necessary to access it by other means, such as by creating a keybind, and/or by - where permitted - re-configuring an installed panel to use the desktop menu as a panel menu. To use xfdesktop to provide icons, add the following command to the ~/.config/openbox/autostart file:

xfdesktop &

conky reconfiguration

Particularly where using a file manager to manage the desktop, it will be necessary to edit ~/.conkyrc to change the own_window_type command in order for conky to continue to be displayed (where used). The revised command that should be used is:

own_window_type normal

oblogout

Tip: Where using oblogout, it is best to have a compositor enabled to avoid screen distortion when executed. This is due to the default use of transparancy effects. Alternatively, it is also possible to edit /etc/oblogout.conf and amend the opacity = command setting to remove transparancy altogether.

Designed for Openbox, oblogout is an optional, configurable logout script that presents a graphical interface (i.e. buttons) to cancel, logout, restart, shutdown, suspend, hibernate, and lock the screen. It may be executed as keybind and/or as a desktop menu entry.

For example, to execute the script by pressing Super+x (i.e. create a keybind for it), edit ~/.config/openbox/rc.xml to add the following to the appropriate part of the <keyboard> section:

<keybind key="W-x">
 <action name="Execute">
  <startupnotify>
   <enabled>true</enabled>
    <name>oblogut</name>
  </startupnotify>
  <command>oblogout</command>
 </action>
</keybind>

Suspend and Hibernate Functionality

oblogout has been configured by default to use the now-deprecated Upower package for suspension and hibernation functionality, meaning that they will not work. However, it is possible to easily fix this problem by using Systemd to take over these functions. To do so, edit the /etc/oblogout.conf file, and find the following section:

[commands]
shutdown = systemctl poweroff
restart = systemctl reboot
suspend = dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Suspend
hibernate = dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Hibernate

Amend the suspend and hibernate commands accordingly to allow Systemd to take over:

suspend = systemctl suspend
hibernate = systemctl hibernate

Screen locking

It will be necessary to edit /etc/oblogout.conf to change the lock = command under the [commands] section, in order to execute the desired package installed for this purpose.

For example, where having installed XScreenSaver - which must itself also be autostarted as a Daemon process in the ~/.config/openbox/autostart file - then /etc/oblogout.conf would be edited accordingly:

lock = screensaver-command --lock

Otherwise, where a package such as xlockmore has been installed - which does not need to be autostarted - then an example of the necessary command (to lock with a blank screen) would be:

lock = xlock -mode blank

Button theme

The default button theme is oxygen. A few other themes are also available, including the pre-installed (and more elegant) foom. To change the button theme, edit /etc/oblogout.conf and change the buttontheme = command under the [looks] section. An example has been provided below for foom:

buttontheme = foom

Button display

Tip: where changing the order of and/or removing buttons, it is best to use a copy of the default button list, and hash the original. There will then be no need to memorise them.

Default buttons are available to cancel, logout, restart, shutdown, suspend, hibernate, and lock the screen. Each button also has a configurable shortcut key assigned (e.g. once oblogout has been executed, the system may then be shutdown by pressing the s key, for example).

Both the buttons presented and their order may be configured to suit personal preference. To do so, edit/etc/oblogout.conf and change the buttons = command under the [looks] section. In the example below, the suspend and hibernate buttons have been removed:

buttons = cancel, logout, lock, restart, shutdown
#buttons = cancel, logout, restart, shutdown, suspend, hibernate, lock

Where removing or adding buttons, it will also be necessary to amend the appropriate shortcut key commands under the [shortcuts] section. Not doing so will mean, for example, that it will still be possible to execute certain functions via the keyboard even where the buttons for them have been removed. For the example provided above, it will be necessary to hash out the suspend and hibernate shortcuts:

[shortcuts]
cancel = Escape
shutdown = S
restart = R
#suspend = U
logout = L
lock = K
#hibernate = H

Openbox for multihead users

While Openbox provides better than average multihead support on its own, the openbox-multihead-gitAUR package from the AUR provides a development branch called Openbox Multihead that gives multihead users per-monitor desktops. This model is not commonly found in floating window managers, but exists mainly in tiling window managers. It is explained well on the Xmonad web site. Also, please see README.MULTIHEAD for a more comprehensive description of the new features and configuration options found in Openbox Multihead.

Openbox Multihead will function like normal Openbox when only a single head is available.

A downside to using Openbox Multihead is that it breaks the EWMH assumption that one and only one desktop is visible at any time. Thus, existing pagers will not work well with it. To remedy this, pager-multihead-gitAUR can be found in the AUR and is compatible with Openbox Multihead. Screenshots.

Finally, a new version of PyTyle that will work with Openbox Multihead can also be found in the AUR: pytyle3-gitAUR.

Both pytyle3 and pager-multihead-git will work without Openbox Multihead if only one monitor is active.

Recommended programs

Template:Box

Tips and tricks

File associations

Merge-arrows-2.pngThis article or section is a candidate for merging with Default Applications.Merge-arrows-2.png

Notes: not specific to openbox (Discuss in Talk:Openbox#)

Because Openbox and the applications you use with it are not well-integrated you might run into the issues with your browser. Your browser may not know which program it is supposed to use for certain types of files.

A package in the AUR called gnome-defaults-listAUR contains a list of file-types and programs specific to the Gnome desktop. The list is installed to /etc/gnome/defaults.list.

Open this file with your text editor. Here you can replace a given application with the name of the program of your choosing. For example, replace totem with vlc  or  eog with mirage. Save the file to ~/.local/share/applications/defaults.list.

Another way of setting file associations is to install package perl-file-mimeinfo from the official repositories and invoke mimeopen like this:

$ mimeopen -d /path/to/file

You are asked which application to use when opening /path/to/file:

Please choose a default application for files of type text/plain
       1) notepad  (wine-extension-txt)
       2) Leafpad  (leafpad)
       3) OpenOffice.org Writer  (writer)
       4) gVim  (gvim)
       5) Other...

Your answer becomes the default handler for that type of file. Mimeopen is installed as /usr/bin/perlbin/vendor/mimetype.

Copy and paste

From a terminal Ctrl+Ins for copy and Shift+Ins for paste.

Also Ctrl+Shift+c for copy and mouse middle-click for paste (in terminals).

Other applications most likely use the conventional keyboard shortcuts for copy and paste.

Window transparency

The program transset-df is available in the official repositories. With transset-df you can enable window transparency on-the-fly.

For instance by placing the following in the <mouse> section you can have your mouse adjust window transparency by scrolling while hovering over the title bar:

~/.config/openbox/rc.xml
<context name="Titlebar">
    . . .
    <mousebind button="Up" action="Click">
        <action name= "Execute" >
        <execute>transset-df -p .2 --inc  </execute>
        </action>
    </mousebind>
    <mousebind button="Down" action="Click">
        <action name= "Execute" >
        <execute>transset-df -p .2 --dec </execute>
        </action>
    </mousebind>
      . . .
</context>
Warning: It appears to work only when no additional actions are defined within the action group.

Xprop values for applications

Xprop can be installed with the package xorg-xprop, available in the official repositories.

If you use per-application settings frequently, you might find this bash alias handy:

alias xp='xprop | grep "WM_WINDOW_ROLE\|WM_CLASS" && echo "WM_CLASS(STRING) = \"NAME\", \"CLASS\""'

To use, run xp and click on the running program that you would like to define with per-app settings. The result displays only the info that Openbox requires, namely the WM_WINDOW_ROLE and WM_CLASS (name and class) values:

$ xp
WM_WINDOW_ROLE(STRING) = "roster"
 WM_CLASS(STRING) = "gajim.py", "Gajim.py"
 WM_CLASS(STRING) = "NAME", "CLASS"

Xprop for Firefox

For whatever reason, Firefox and like-minded equivalents ignore application rules (e.g. <desktop>) unless class="Firefox*" is used. This applies irrespective of whatever values xprop may report for the program's WM_CLASS.

Switching between keyboard layouts

If you don't want to use a separate program for managing keyboard layouts, you can manually configure X to switch layouts on certain key combinations. See Keyboard Configuration in Xorg#Switching between keyboard layouts for instructions.

Troubleshooting

Windows load behind the active window

Some application windows (such as Firefox windows) may load behind the currently active window, causing you to need to switch to the window you just created to focus it. To fix this behavior add this to your ~/.config/openbox/rc.xml file, inbetween the <openbox_config> and </openbox_config> tags:

<applications>
  <application class="*">
    <focus>yes</focus>
  </application>
</applications>

See also