Roll your own Linux desktop using Openbox

Last updated on 2021-11-26 Tagged under  # openbox  # debian  # linux

A window manager like Openbox handles the "drawing" of windows on a display, and typically run underneath heavier full-desktop X environments. However - given a few tweaks, add a few applications, and a fresh splash of "paint" (themes) - Openbox can run in standalone mode and makes an excellent foundation for a custom lightweight and delightful Linux desktop!

Let's go!

I start with a bare display and pick and choose components to make a desktop just the way I like it. Some advantages of a self-assembled Openbox desktop:

Setup is done on my laptop running Debian.

1. Install

Install Openbox and copy default config files to $HOME ...

$ sudo apt install openbox obconf menu
$ mkdir -p ~/.config/openbox
$ cp /etc/xdg/openbox/* ~/.config/openbox/

Install custom desktop extras ...

$ sudo apt install diodon dunst dbus-x11 feh hsetroot i3lock libnotify-bin lximage-qt network-manager network-manager-gnome pavucontrol-qt pmount pulseaudio-utils rofi scrot tint2 volumeicon-alsa xfce4-power-manager
$ sudo apt install adwaita-qt gnome-themes-standard gtk2-engines-murrine gtk2-engines-pixbuf fonts-dejavu fonts-firacode fonts-liberation2 fonts-ubuntu qt5-style-plugins lxappearance papirus-icon-theme

My default mode is to login via console, then run startx to launch an X environment.

Add openbox-session to ~/.xinitrc ...

exec openbox-session

... save, run startx, and behold ...


Hmm ... default Openbox is a grey blank fixer-upper desktop.

2. Config: rc.xml

Most of the desktop configuration details for the user are set in ~/.config/openbox/rc.xml.

2.1 Add desktops

I have Openbox create four desktops at launch ...


2.2 Keybindings

I create hotkey keybindings that perform a range of actions: switch desktops, move windows, launch menus, lock/suspend/exit the system.

2.3 Decorations

Set default condition that matches all application windows and maximize + remove decorations when launched. Leave things like dialog windows or panels untouched ...

<application type="normal">

... except for VLC media player ...

<application class="vlc">


2.4 Lock screen

I use i3lock launched from a keybinding (windows key + l) to lock my screen, or to work in concert with systemctl to lock screen when suspend (windows key + s) is activated. Set a custom lockscreen image in ~/.i3lock.png ...

    <!-- Keybindings for [l]ock screen, [s]uspend, [e]xit -->
    <keybind key="W-l">
      <action name="Execute">
        <command>i3lock -c 000000 -i ~/.i3lock.png</command>
    <keybind key="W-s">
      <action name="Execute">
        <command>sh -c 'i3lock -c 000000 -i ~/.i3lock.png; sync; systemctl suspend'</command>

3. Config: menu.xml

Openbox includes a system menu that appears on a right-click on the desktop. Modifications go in ~/.config/openbox/menu.xml.

Example: I add a screenshot sub-menu that calls on scrot to capture the image and lximage-qt to display it. Add some screenshot options to menu.xml ...

<menu id="scrot-menu" label="Screenshots">
<item label="Now">
    <action name="Execute"><execute>
        scrot -d 1 -u -z 'screenshot-%Y-%m-%dT%H%M%S.png' -e 'mv $f ~/image/screenshot &amp; lximage-qt ~/image/screenshot/$f'
<item label="In 5 Seconds...">
    <action name="Execute"><execute>
        scrot -d 5 -u -z 'screenshot-%Y-%m-%dT%H%M%S.png' -e 'mv $f ~/image/screenshot &amp; lximage-qt ~/image/screenshot/$f'
<item label="Selected Area...">
    <action name="Execute"><execute>
        scrot -s 'screenshot-%Y-%m-%dT%H%M%S.png' -e 'mv $f ~/image/screenshot &amp; lximage-qt ~/image/screenshot/$f'
<item label="Desktop">
    <action name="Execute"><execute>
        scrot 'screenshot-%Y-%m-%dT%H%M%S.png' -e 'mv $f ~/image/screenshot &amp; lximage-qt ~/image/screenshot/$f'

Result ...


4. Launch applications

For choosing and launching applications I use rofi, a dynamic applications menu utility. I set a keybinding in rc.xml (windows key + spacebar) that launches an applications menubar across the top of the display and, as I type the name of the application, the menu zooms in on matching names. Most frequently-used applications rise to the beginning of the list for quick access.

Menu behaviour and appearance can be modified in ~/.config/rofi.

5. Config: environment

Set user-specific environment variables in ~/.config/openbox/environment. I don't use it myself because most of the relevant settings are configured elsewhere. But if I wanted to configure something to be Openbox-specific this is probably a good place to do so.

6. Config: autostart

Actions and applications to be launched when starting Openbox are configured in ~/.config/openbox/autostart.

6.1 Background

I use hsetroot to set the background colour, and the feh image viewer to set a background image for the desktop ...

$ feh --bg-scale /path/to/your/background/image.jpg

Once an image is chosen, feh stores its name in ~/.fehbg. Add entry to autostart to restore the background on next launch ...

hsetroot -solid "#000000"
(sleep 1; ~/.fehbg) &

6.2 Laptop + external display

I created a shell script to detect when my laptop is connected to an external display, and make that secondary (larger) display register as PRIMARY display (windows default to opening on PRIMARY) ...

~/bin/dldsply -r &

6.3 Power management

Use xfce4-power-manager to handle AC and battery power events, screen brightness, suspend system, suspend-on-lid-closure for laptops, etc. ...

xfce4-power-manager &

6.4 Notifications

Use dunst - a lightweight notification daemon - for desktop events. Configure the daemon in ~/.config/dunst/dunstrc ...

dunst -config ~/.config/dunst/dunstrc &

6.5 Panel

I use tint2 as my desktop panel. Highly configurable with few dependencies. Provides items like a taskbar, system tray, battery indicator, and clock ...

tint2 &

Configuration is set in ~/.config/tint2/tint2rc. My own was inspired by these colourful samples.

6.6 Clipboard

Desktop clipboard diodon for multiple-entry copy-paste operations ...

diodon &

6.7 Volume control

Volumeicon-alsa places a volume icon in the system tray ...

volumeicon &

Right-click on the icon, select Preferences, and change the external mixer to pavucontrol-qt.

6.8 Network manager

Use network-manager to manage wired and wireless connections, and nm-applet to place a network menu in the system tray. An autostart desktop file in /etc/xdg/autostart/nm-applet.desktop launches nm-applet whenever an Openbox session begins.

Comment out and disable entries in /etc/network/interfaces for any network devices to be managed instead by network-manager ...

# The primary network interface
#allow-hotplug enp0s25
#iface enp0s25 inet dhcp

Restart ...

$ sudo systemctl restart network-manager

Add entry to autostart ...

nm-applet &

7. Themes

Style the desktop with a combination of themes, colours, icons, and fonts. I like the Nord colour pallete.

7.1 GTK

Create ~/.themes ...

$ mkdir ~/.themes

Download the Nordic theme, and copy Nordic to ~/.themes/Nordic. Select using the lxappearance utility. Pairs nicely with Papirus Dark icon set.

7.2 Openbox

Download the Nordic-Openbox theme, and copy to ~/.themes/. Select using the obconf utility.

7.3 QT

Use qt5-style-plugins to style QT apps with the chosen GTK theme. Add entry to ~/.profile ...


7.4 Terminal

Use xfce4-terminal as the terminal with Fira Code fonts and Nord-inspired colours.

8. End result

From grey screen to the good stuff ...

Openbox custom

8.1 Dotfiles and script

» Later: Build a Debian package from source using checkinstall

« Earlier: Not so minimal Debian