Roll your own Linux desktop using Openbox
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!
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:
- pick and mix your own desktop components
- lower memory requirements, runs quick on older hardware
- easy to modify by editing text files
- greater appreciation of how an X environment works!
Setup is done on my laptop running Debian.
Install Openbox and copy default config files to
$ 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 network-manager network-manager-gnome pavucontrol pmount pulseaudio-utils rofi rxvt-unicode scrot tint2 viewnior volumeicon-alsa xfce4-power-manager $ sudo apt install gnome-themes-standard gtk2-engines-murrine gtk2-engines-pixbuf fonts-dejavu fonts-firacode fonts-liberation2 fonts-ubuntu adwaita-qt 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 ...
... save, run
startx, and behold ...
Hmm ... out-of-box Openbox is a grey blank canvas just begging for some love!
Most of the desktop configuration details for the user are set in ~/.config/openbox/rc.xml.
* Add desktops
I have Openbox create four desktops at launch ...
<desktops> <number>4</number> <firstdesk>1</firstdesk> <names> <name>1</name> <name>2</name> <name>3</name> <name>4</name> </names> <popupTime>0</popupTime> </desktops>
I create hotkey keybindings that perform a range of actions: switch desktops, move windows, launch menus, lock/suspend/exit the system.
Set default condition that matches all application windows and maximize + remove decorations when launched. Leave things like dialog windows or panels untouched ...
<applications> <application type="normal"> <maximized>true</maximized><decor>no</decor> </application>
... except for VLC media player ...
<application class="vlc"> <maximized>false</maximized><decor>yes</decor> </application>
* 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. Add to
<!-- Keybindings for [l]ock screen, [s]uspend, [e]xit --> <keybind key="W-l"> <action name="Execute"> <command>i3lock -c 000000 -i ~/.i3lock.png</command> </action> </keybind> <keybind key="W-s"> <action name="Execute"> <command>sh -c 'i3lock -c 000000 -i ~/.i3lock.png; sync; systemctl suspend'</command> </action> </keybind>
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 viewnior to display it. Add some screenshot options to
<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 & viewnior ~/image/screenshot/$f' </execute></action> </item> <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 & viewnior ~/image/screenshot/$f' </execute></action> </item> <item label="Selected Area..."> <action name="Execute"><execute> scrot -s 'screenshot-%Y-%m-%dT%H%M%S.png' -e 'mv $f ~/image/screenshot & viewnior ~/image/screenshot/$f' </execute></action> </item> <item label="Desktop"> <action name="Execute"><execute> scrot 'screenshot-%Y-%m-%dT%H%M%S.png' -e 'mv $f ~/image/screenshot & viewnior ~/image/screenshot/$f' </execute></action> </item> </menu>
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.
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.
Actions and applications to be launched when starting Openbox are configured in ~/.config/openbox/autostart.
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) &
* 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).
Add entry to
~/bin/dldsply -r &
* Power management
Use xfce4-power-manager to handle AC and battery power events, screen brightness, suspend system, suspend-on-lid-closure for laptops, etc. Add entry to
Dunst is a lightweight notification daemon for desktop events. Configure the daemon in ~/.config/dunst/dunstrc. Add entry to
dunst -config ~/.config/dunst/dunstrc &
I use tint2 as my desktop panel. Highly configurable with few dependencies. Provides items like a taskbar, system tray, battery indicator, and clock. Configuration is set in ~/.config/tint2/tint2rc. My own config was inspired by these colourful samples. Add entry to
Desktop clipboard clipit for multiple-entry copy-paste operations. Add entry to
* Volume control
Volumeicon-alsa places a volume icon in the system tray. Add entry to
Right-click on the icon, select
Preferences, and change the external mixer to pavucontrol.
* Network manager
Network-Manager is my choice to manage wired and wireless connections. Use nm-applet to place a network menu in the system tray. An autostart desktop file in
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
$ sudo systemctl restart network-manager
Add entry to
Style the desktop with a combination of themes, colours, icons, and fonts. I like the Nord colour pallete.
$ mkdir ~/.themes
Download the Nordic theme, unzip, and copy
~/.themes/Nordic. Select using the lxappearance utility. Pairs nicely with Papirus Dark icon set.
Download the Nord Openbox theme, unpack, and copy to
~/.themes/. Select using the obconf utility.
Use qt5-style-plugins to style QT apps with the chosen GTK theme. Add entry to ~/.profile ...
I use urxvt as my terminal with Fira Code fonts and Nord-inspired colours. Configuration is set in ~/.Xresources.
From grey screen to the good stuff ...
- My configs:
» Later: Secure remote access using SSH keys
« Earlier: Virtualbox on Debian Buster