How to Install and Configure Openbox Using Ubuntu

Try out a more minimal approach to your Ubuntu desktop

Unbuntu interface on computer screen

unsplash / Mock Up Photos

Since 2017 the Ubuntu Linux distribution has used GNOME as the default desktop environment. In most cases, this is a perfectly decent user interface that integrates well with countless themes and plugins.

Sometimes, however, if you have an older machine you will want something a little bit lighter, such as Xubuntu Linux, which uses the XFCE desktop, or Lubuntu, which uses the LXDE desktop. Other distributions, like 4M Linux, use much lighter window managers, such as JWM or IceWM.

You can make something equally as lightweight by using the Openbox window manager. This is a fairly bare-bones window manager that you can build upon and customize as you so desire.

This guide shows you the basics of setting up Openbox within Ubuntu, how to alter the menus, how to add a dock, and how to set the wallpaper.

As of Ubuntu 20.04, the Openbox menu configuration tool, obmenu, (covered later in this guide) was removed due to technical conflicts with other software. While it's still possible to install and use Openbox on Ubuntu, customizing the menus can only be done by editing more complex text files.

Install Openbox on Ubuntu

Installing Openbox

To install Openbox open a terminal window (Press CTRL, ALT, and T) at the same time or search for "TERM" within the dash and select the icon.

  1. Type the following command:

    sudo apt install openbox obconf
    
  2. Click on the icon in the upper-right corner, then log out.

How to Switch to Openbox

Follow these steps to switch to Openbox.

  1. From the login screen, select your username as you normally would.

  2. When the screen expands to let you enter your password, select the gear icon in the lower-right corner of the screen. A dialog will appear with the following options:

    • Openbox
    • Ubuntu
    • Ubuntu on Wayland
    Ubuntu choose Openbox desktop
  3. Choose Openbox, then sign in as normal.

The Default Openbox Screen

The default Openbox screen is a fairly bland looking screen. Right-clicking on the desktop will bring up a menu. That's all there is to it at the moment. To start the customization process, bring up the menu and choose Terminal.

Ubuntu default Openbox desktop

Change the Openbox Wallpaper

Here's how to change the Openbox Wallpaper.

  1. Start by setting your display resolution. Chances are, Openbox didn't get it right to start with. Open a terminal window, and run the xrandr command to set the display resolution:

    xrandr -s 1920x1080
    

    You can also include a monitor refresh rate in there to set a specific one:

    xrandr -s 1920x1080 -r 60
    
  2. Next, create a folder for your wallpaper:

    mkdir ~/Pictures/wallpaper
    
  3. Copy some wallpaper images into the folder. If you want some new ideas, check out Unsplash. Everything on there is high resolution and completely free to use.

  4. The program that we will use to set the wallpaper background is called feh.

    Ubuntu install feh

    To install feh, run the following command:

    sudo apt install feh
    
  5. When the application has finished installing, type the following command for setting the initial background:

    feh --bg-scale ~/Pictures/wallpaper/<nameofpicture>
    

    Replace <nameofpicture> with the name of the image you wish to use as the background.

    Ubuntu Openbox set wallpaper with feh
  6. This will only temporarily set the background. To set the background every time you log in you will need to create an autostart file, such as follows:

    cd ~/.config
    mkdir openbox
    cd openbox
    nano autostart
  7. Add your xrandr command to the file so that Openbox automatically uses the correct resolution.

  8. In the autostart file, enter the following command:

    sh ~/.fehbg &
    

    The ampersand (&) is incredibly important as it runs the command in the background, so do not leave it out.

    Ubuntu Openbox autostart

    Altogether, it should look something like this:

    xrandr -s 1920x1080 -r 60
    sh ~/.fehbg &

Add a Dock to Openbox

While the desktop now looks a little bit nicer, it would be good to have a way of launching applications. To do this you can install Cairo, which is a fairly classy-looking dock. The first thing you need to do is install a compositing manager.

  1. Open up a terminal window and enter the following code:

    sudo apt install xcompmgr
    
  2. Now install Cairo as follows:

    sudo apt install cairo-dock
    
    Install Cairo Dock on Ubuntu
  3. Open the autostart file again by running the following command:

    nano ~/.config/openbox/autostart
    
  4. Add the following lines to the bottom of the file:

    xcompmgr &
    cairo-dock -o &
    Ubuntu Openbox configure Cairo Dock autostart
  5. You should be able to restart Openbox to make this work by typing the following command:

    openbox --reconfigure
    

    If the above command doesn't work, log out and log back in again. A message may appear asking whether you wish to use OpenGL or not. Select Yes to continue.

  6. The Cairo dock should now load and you should be able to access all of your applications.

    Ubuntu Openbox with Cairo Dock

    Right-click on the dock and choose the configuration option to play with the settings.

Adjusting the Right-Click Menu

This is the part that no longer works on Ubuntu 20.04. The issue was caused by Ubuntu's switch to Python 3. The obmenu utility uses an outdated piece of software only compatible with Python 2. As a result, the Ubuntu developers didn't add it to the 20.04 repositories. This may change sometime in the future.

Adjust Right Click Menu

Here is how to adjust the right-click menu.

Open a terminal again and run the following commands:

cp /var/lib/openbox/debian-menu.xml ~/.config/openbox/debian-menu.xml
cp /etc/X11/openbox/menu.xml ~/.config/openbox
cp /etc/X11/openbox/rc.xml ~/.config/openbox
openbox --reconfigure

Now when you right-click on the desktop you should see a new Debian menu with an applications folder that links to the applications installed on your system.

Adjust the Menu Manually

Adjust Openbox Menu

 If you want to add your own menu entries you can use the graphical application called Obmenu.

  1. Open a terminal and type the following:

    obmenu &
    

    A graphical utility will load.

  2. To add a new sub menu, select where you want the sub menu to be in the list and select New Menu.

  3. You will be asked to enter a label. To add a link to a new application, select the New Item.

  4. Enter a label (i.e. a name) and then enter the path to the command to execute. You can also press the button with three dots on it and navigate to the /usr/bin folder or any other folder to find the file or program to run.

  5. To remove items, select the item to remove and press the small black arrow to the right of the toolbar, then choose Remove.

  6. Finally, you can enter a separator by choosing where you want the separator to appear and selecting New Separator

Configuring Openbox Desktop Settings

To adjust general desktop settings either right-click on the menu and choose obconf or enter the following in a terminal:

obconf &

The editor is split into a number of tabs as follows:

  • Theme
  • Appearance
  • Windows
  • Move & Resize
  • Mouse
  • Desktop
  • Margins
  • Dock
Ubuntu Openbox theme settings

The Theme window lets you adjust the look and feel of the windows within Openbox. There are a number of default themes, but you can download and install some of your own.

Ubuntu Openbpx appearance settings

The Appearance window lets you adjust settings such as font styles, sizes, whether windows can be maximized, minimized, behavior codified, closed, rolled up, or present on all desktops.

Ubuntu Openbox window settings

The Windows tab lets you see the behavior of windows. For example you can automatically focus on a window when the mouse hovers over it, and you can set where to open new windows.

Ubuntu Openbox move settings

The Move & Resize window lets you decide how close windows can get to other windows before there is some resistance, and you can set whether to move applications to new desktops when they are moved off the edge of a screen.

Ubuntu Openbox mouse settings

The Mouse window lets you decide how windows get focused as the mouse hovers over them, and it lets you decide how a double-click affects a window.

Ubuntu Openbox desktop settings

The Desktop window lets you decide how many virtual desktops there are and how long a notification is shown stating that you are about to switch desktops.

Ubuntu Openbox margin settings

The Margins window lets you specify a margin around the screen whereby a window cannot pass over them. 

Ubuntu Openbox dock settings

The Dock tab lets you control select settings for your dock. It's not referring to Cairo. Rather, these settings apply should you choose to install a more traditional panel, like Tint2.