mike chambers | about

Installing Openbox on Arch Linux

I have been spending some time the past week playing around with Arch Linux. I really like the approach of a bare bones install and understanding every single thing on your system. However, this can lead to some frustration when you are first starting out (my first install I ended up without a network, any fonts or a kernel!).

Anyways, I think the most workable barebones install of Arch Linux is basically the base Linux install with a window manager. This post quickly covers the steps for installing and configuring the Openbox window manager on a fresh Arch Linux install.

Install Openbox

In order to get a bare minimum install of Openbox up and running you need to install the xorg-server and xorg-xinit packages.

sudo pacman -S xorg-server xorg-xinit

This installs the core Openbox server, as well as the initialization files which we will use below to customize the install.

Install Fonts

Next, if you didn’t explicitly install fonts when installing Arch Linux, you need to install some now. Otherwise, the context menus in Arch Linux will be blank.

To get started you can install the xorg-fonts-misc package:

pacman -S xorg-fonts-misc

You can find other fonts to install here. I suggest you find a good monospace font to install, or else terminal rendering might be messed up.

Configure Openbox

Next, we need to create a default xinitrc script. This is run when you call startx to launch your window manager, and is used to configure how its run and which window manager is launched:

cp /etc/X11/xinit/xinitrc ~/.xinitrc

Now, open ~/.xinitrc and go to the end of the file. You can comment out all of the xterm apps being executed (as they may not be installed and may cause errors). Add the following at the very end:

exec openbox-session

This tells X to launch Openbox when your run startx.

Save and close the file. At this point you can launch Openbox via:

startx

and Openbox should launch. By default, you will just get a blank screen. If you right click with your mouse, you will get a default context menu, which you can use to launch other apps as well as end your Openbox session.

Note, the menu has a bunch of entries which you probably don’t have setup or installed. You need to manually customize the menu by editing an XML file.

Run the following commands to setup the configuration for Openbox (you might need to close Openbox to get back to a command prompt):

mkdir -p ~/.config/openbox
cp -a /etc/xdg/openbox/ ~/.config/

This will copy 4 files into the ~/.config/openbox directory

rc.xml is used for general configuration in Openbox, including customizing window and desktop placement on a per app basis (i.e. always open Firefox full screen on desktop 2).

menu.xml is used to setup and customize the context menu in Openbox. It comes pre-populated with items which are pretty easy to customize. I suggest you at least add an entry to launch a Terminal program.

Finally, the autostart file can be used to add apps which you want to have automatically launched when Openbox starts. For example, I automatically launch a couple of terminal windows (using the kitty terminal) when I start Openbox.

exec kitty
exec kitty vim ~/docs/notes.md

At this point, you have the basics to start using windowed apps in Arch Linux. Now you can start to customize things to work how you want (i.e. window and desktop management and switching, hotkeys, etc…), as well as installing other apps such as wallpaper managers, file managers, etc…

One thing that is really helpful is to learn some of the default keyboard shortcuts. You can find a good overview of them here.

UPDATE (Nov 7, 2020) : Just a couple of quick follow up notes on this. First, Openbox uses the XDG_CONFIG_HOME environment variable to find custom config files. Here is how I have mine setup in my .bashrc:

export XDG_CONFIG_HOME=$HOME/.config/

.config contains a folder named openbox that contains all of the config file.

If you run into an issue where your custom config files are not being used, then make sure this is set correctly.

Secondly, I would suggest you also install xdg-utils:

sudo pacman -S xdg-utils

This is useful for handling URLs within openbox (i.e. I ran into an issue where I couldn’t authenticate in Visual Studio Code because it was trying to launch the browser but couldn’t).

twitter github flickr behance