Time to cut the bullshit and actually make some real configuration. In today’s article of the FreeBSD Desktop series I will describe how to configure the Openbox window manager.

You may want to check other articles in the FreeBSD Desktop series on the FreeBSD Desktop – Global Page where you will find links to all episodes of the series along with table of contents for each episode’s contents.

Features

Comparing to earlier articles in the series it will be HUGE, sorry for that. I could cut it into smaller parts but that would require editing of the Openbox configuration, its shortcuts and menus over and over again, so for the sake of simplicity its better to put it all at once. As it is as that big there will be mistakes, but I will fix them ASAP.

Here is the list of all features that will be available in this Openbox configuration.

Nice looking Openbox theme.

Openbox Menu (static) with nice looking icons.

Openbox Menu for FreeBSD top(1) / ps(1) commands and config files/logs.

/ commands and config files/logs. Openbox Menu for FreeBSD default sound output.

Openbox Menu and shortcuts for FreeBSD sound volume increase/decrease.

Openbox Menu for FreeBSD for CPU frequency scaling.

Openbox Menu for FreeBSD network management with network.sh script.

script. Openbox Menu for screenshots/wallpapers management.

Openbox Menu for Recent files.

Random wallpaper handling.

Random xterm(1) theme at every terminal start with lost of great themes.

theme at every terminal start with lost of great themes. Openbox shortcuts and script for Aero Snap like behavior.

Openbox Dmenu shortcuts and integration.

Openbox configured with nice fonts.

Openbox shortcuts for most important tasks.

Warning for low battery on laptop.

I probably forgot about dozen other features – let me know in comments 🙂

Here is how the Openbox menus and window borders and window switching would look like.

Here are all the files with needed configuration.

Doas

To make most scripts work Your user ( vuk in the series) needs to be in the wheel , operator and network groups and doas(1) ( sudo(8) equivalent) needs to be installed and configured in the following way.

# pkg install doas # pw groupmod wheel -m vuk # pw groupmod operator -m vuk # pw groupmod network -m vuk # cat /usr/local/etc/doas.conf permit nopass :wheel as root permit nopass :network as root cmd ifconfig permit nopass :network as root cmd dhclient permit nopass :network as root cmd umount permit nopass :network as root cmd wpa_supplicant permit nopass :network as root cmd ppp permit nopass :network as root cmd killall args -9 dhclient permit nopass :network as root cmd killall args -9 wpa_supplicant permit nopass :network as root cmd killall args -9 ppp permit nopass :network as root cmd cat args /etc/ppp/ppp.conf permit nopass :network as root cmd /etc/rc.d/netif args onerestart permit nopass :network as root cmd tee args /etc/resolv.conf permit nopass :network as root cmd tee args -a /etc/resolv.conf

Scripts

In this post I attach scripts I have made and used for about 13 years since I started to use FreeBSD on the desktop. Download them all in the scripts.tar.gz file and unpack them into the ~/scripts to make it look like that.

% find scripts | sort scripts/__openbox_cpufreq.sh scripts/__openbox_current_wallpaper.sh scripts/__openbox_delete_wallpaper.sh scripts/__openbox_dmenu.sh scripts/__openbox_edit_screenshot.sh scripts/__openbox_edit_wallpaper_gimp.sh scripts/__openbox_freebsd_sound.sh scripts/__openbox_lock_zzz.sh scripts/__openbox_lock.sh scripts/__openbox_recent.sh scripts/__openbox_reload_wallpaper.sh scripts/__openbox_restart_conky.sh scripts/__openbox_restart_dzen2.sh scripts/__openbox_restart_plank.sh scripts/__openbox_restart_tint2.sh scripts/__openbox_show_screenshot.sh scripts/__openbox_stats_ps_KILLALL.sh scripts/__openbox_stats_top_cpu_KILL.sh scripts/__openbox_stats_top_cpu_RENICE.sh scripts/__openbox_stats_top_mem_KILL.sh scripts/__openbox_stats_top_mem_RENICE.sh scripts/aero-snap.sh scripts/fc-cache.sh scripts/firefox-clean.sh scripts/network.sh scripts/random_wallpaper.sh scripts/shot.sh scripts/xterm.sh scripts/desktop-kill-shit.sh scripts/desktop-battery-warning.sh

Make sure they remain executable.

% chmod +x ~/scripts/*

To make them work properly add ~/scripts into the ${PATH} variable at the beginning of the ~/.xinitrc file.

# PATH TO SCRIPTS export PATH=${PATH}:~/scripts

All of my scripts have this ‘mysterious’ line at the end. Its for statistics to check which scripts are run when (or it at all to which ones to delete).

echo '1' >> ~/scripts/stats/$( basename ${0} )

Thus it is needed to create the ‘stats’ directory.

% mkdir -p ~/scripts/stats

I have implemented that about two months ago and here are the results.

% wc -l ~/scripts/stats/* | sort -n 1 /home/vermaden/scripts/stats/__openbox_show_screenshot.sh 2 /home/vermaden/scripts/stats/__openbox_cpufreq.sh 2 /home/vermaden/scripts/stats/__openbox_current_wallpaper.sh 2 /home/vermaden/scripts/stats/__openbox_fullscreen.sh 4 /home/vermaden/scripts/stats/__openbox_restart_dzen2.sh 4 /home/vermaden/scripts/stats/dzen2-fifo.sh 5 /home/vermaden/scripts/stats/__openbox_dmenu.sh 5 /home/vermaden/scripts/stats/__openbox_restart_conky.sh 5 /home/vermaden/scripts/stats/__openbox_restart_tint2.sh 6 /home/vermaden/scripts/stats/__openbox_delete_wallpaper.sh 7 /home/vermaden/scripts/stats/__openbox_freebsd_sound.sh 8 /home/vermaden/scripts/stats/aero-snap.sh 12 /home/vermaden/scripts/stats/__openbox_edit_screenshot.sh 16 /home/vermaden/scripts/stats/__openbox_lock_zzz.sh 16 /home/vermaden/scripts/stats/__openbox_lock.sh 22 /home/vermaden/scripts/stats/shot.sh 24 /home/vermaden/scripts/stats/network.sh 214 /home/vermaden/scripts/stats/xterm.sh 960 /home/vermaden/scripts/stats/random_wallpaper.sh 2767 /home/vermaden/scripts/stats/desktop-battery-warning.sh 13834 /home/vermaden/scripts/stats/desktop-kill-shit.sh 17916 total

Of course I limited the output only to scripts that are available in this article, but be patient, more to come later 🙂

Dependencies

To make these scripts work and generally to make all this setup work we will need these dependencies.

arandr

qt5ct

qtconfig-qt4

sakura

leafpad

geany

caja

thunar

libreoffice

galculator

pidgin

firefox

chrome

deadbeef

transmission-gtk

gnumeric

abiword

audacity

filezilla

midori

gimp

lupe

xvidcap

zenity

xterm

xrdb

scrot

feh

wmctrl

xdotool

viewnior

tint2

plank

dzen2

conky

mate-screensaver

xlockmore

gimp

dmenu

powerdxx

htop

galculator

To install them all with pkg(8) just type this line below.

# pkg install \ geany caja thunar libreoffice galculator pidgin firefox chrome midori \ abiword deadbeef transmission-gtk gnumeric audacity filezilla zenity \ gimp lupe recorder xvidcap xterm xrdb scrot feh wmctrl xdotool tint2 \ viewnior plank dzen2 conky mate-screensaver xlockmore powerdxx arandr \ qt5ct gfontview galculator qtconfig qtconfig-qt4 sakura leafpad dmenu \ htop

I also assume that wallpapers will be kept under ~/gfx/wallpapers dir and screenshots made under ~/gfx/screenshots directory, so lets create them now.

% mkdir -p ~/gfx/wallpapers % mkdir -p ~/gfx/screenshots

Crontab

Some of these scripts needs to be put into crontab(1) to work, here are their entries.

% crontab -l # DESKTOP * * * * * ~/scripts/desktop-kill-shit.sh 1> /dev/null 2> /dev/null */5 * * * * ~/scripts/desktop-battery-warning.sh */20 * * * * ~/scripts/random_wallpaper.sh ~/gfx/wallpapers 1> /dev/null 2> /dev/null 12,0 * * * * /usr/bin/find ~/.cache -mtime +10 -delete 1> /dev/null 2> /dev/null 0 */3 * * * /usr/bin/find ~/.local/share/Trash/files -mtime +1 -delete 1> /dev/null 2> /dev/null

Fonts

I use Ubuntu Mono font for the Openbox menus and Fira Sans font for the Openbox window bar titles, thus you will download them in the fonts.tar.gz file and extract them like that into the ~/.fonts directory, if if does not exists, create it.

% find .fonts .fonts/fira-sans-bold-italic.otf .fonts/fira-sans-bold.otf .fonts/fira-sans-italic.otf .fonts/fira-sans-regular.otf .fonts/ubuntu-mono-bold-italic.ttf .fonts/ubuntu-mono-bold.ttf .fonts/ubuntu-mono-italic.ttf .fonts/ubuntu-mono-regular.ttf

To make sure that Openbox will ‘see’ them you can verify it using the fc-match(1) command like below.

% fc-match 'Fira Sans' fira-sans-regular.otf: "Fira Sans" "Regular" % fc-match 'Ubuntu Mono' ubuntu-mono-regular.ttf: "Ubuntu Mono" "Regular"

Openbox

Openbox consists mostly of two files.

~/.config/openbox/menu.xml

~/.config/openbox/rc.xml

There are also these two, but its pointless to use them as we set our environment and start our apps/daemons in the ~/.xinitrc file (with ~/.xsession symlink to it), but anyway.

~/.config/openbox/autostart

~/.config/openbox/environment

The icons for the Openbox menu are kept under ~/.config/openbox/icons directory.

Download whole Openbox configuration in the openbox.tar.gz file and unpack it into the ~/.config/openbox to make it look like that.

% find .config/openbox -maxdepth 1 .config/openbox .config/openbox/rc.xml .config/openbox/menu.xml .config/openbox/icons .config/openbox/environment .config/openbox/autostart

Openbox Theme

The theme we will use at start is the Openbox Flat made by myself, I do not remember if I put it online on the https://www.box-look.org/ site but that does not matter. Grab it in the openbox-flat-theme.tar.gz file and unpack it like that into the ~/.themes directory, create it if it does not exists.

% find .themes/openbox_flat .themes/openbox_flat .themes/openbox_flat/openbox-3 .themes/openbox_flat/openbox-3/iconify.xbm .themes/openbox_flat/openbox-3/XPM .themes/openbox_flat/openbox-3/XPM/over.xpm .themes/openbox_flat/openbox-3/XPM/close.xpm .themes/openbox_flat/openbox-3/XPM/max.xpm .themes/openbox_flat/openbox-3/XPM/stick.0.xpm .themes/openbox_flat/openbox-3/XPM/min.xpm .themes/openbox_flat/openbox-3/XPM/shade.xpm .themes/openbox_flat/openbox-3/XPM/stick.1.xpm .themes/openbox_flat/openbox-3/max.xbm .themes/openbox_flat/openbox-3/close.xbm .themes/openbox_flat/openbox-3/bullet.xbm .themes/openbox_flat/openbox-3/shade.xbm .themes/openbox_flat/openbox-3/themerc .themes/openbox_flat/openbox-3/desk.xbm .themes/openbox_flat/openbox-3/desk_toggled.xbm

Openbox FreeBSD Submenus

The ‘system‘ Openbox submenu is for FreeBSD top(1) / ps(1) commands and config files/logs.

The ‘sound‘ Openbox submenu is for FreeBSD default sound output selection.

The ‘recent‘ Openbox submenu is for Recent files.

Check ‘screenshot:‘ and ‘wallpaper:‘ in the ‘x11‘ Openbox submenu for screenshots/wallpapers management.

Check ‘cpu:‘ in the ‘utilities‘ Openbox submenu for FreeBSD for CPU frequency scaling.

Check ‘NETWORK:‘ in the ‘daemons‘ Openbox submenu for FreeBSD network management with network.sh script.

Shortcuts

Lets start with the most basic ones. [SUPER] is the so called Windows key.

Shortcuts – Virtual Desktops

[ALT] + [F1] – switch to 1st virtual desktop.

– switch to 1st virtual desktop. [ALT] + [F2] – switch to 2nd virtual desktop.

– switch to 2nd virtual desktop. [ALT] + [F3] – switch to 3rd virtual desktop.

– switch to 3rd virtual desktop. [ALT] + [F4] – switch to 4th virtual desktop.

– switch to 4th virtual desktop. [SHIFT] + [ALT] + [F1] – move current window to 1st virtual desktop.

– move current window to 1st virtual desktop. [SHIFT] + [ALT] + [F2] – move current window to 2nd virtual desktop.

– move current window to 2nd virtual desktop. [SHIFT] + [ALT] + [F3] – move current window to 3rd virtual desktop.

– move current window to 3rd virtual desktop. [SHIFT] + [ALT] + [F4] – move current window to 4th virtual desktop.

Shortcuts – Menus

[SUPER] + [SPACE] – show Openbox root menu.

– show Openbox root menu. [SUPER] + [ALT] + [SPACE] – show Openbox window list menu.

– show Openbox window list menu. [ALT] + [SPACE] – show current window options menu (client menu).

Shortcuts – Window Management

[ALT] + [TAB] – cycle windows focus forward.

– cycle windows focus forward. [SHIFT] + [ALT] + [TAB] – cycle windows focus backward.

– cycle windows focus backward. [CTRL] + [ALT] + [Q] – close current window.

– close current window. [CTRL] + [ALT] + [F] – put current window info fullscreen.

– put current window info fullscreen. [ALT] + [Up] – shade current window.

– shade current window. [ALT] + [Down] – minimize current window.

– minimize current window. [ALT] + [ESC] – send current window below all other windows.

Shortcuts – Advanced Aero Snap

[SUPER] + [Up] – move window to half of the screen from top.

– move window to half of the screen from top. [SUPER] + [Down] – move window to half of the screen from bottom.

– move window to half of the screen from bottom. [SUPER] + [Left] – move window to half of the screen from left.

– move window to half of the screen from left. [SUPER] + [Right] – move window to half of the screen from right.

– move window to half of the screen from right. [SUPER] + [CTRL] + [Up] – move window to top-left part of the screen.

– move window to top-left part of the screen. [SUPER] + [CTRL] + [Down] – move window to bottom-left part of the screen.

– move window to bottom-left part of the screen. [SUPER] + [ALT] + [Up] – move window to top-right part of the screen.

– move window to top-right part of the screen. [SUPER] + [ALT] + [Down] – move window to bottom-right part of the screen.

– move window to bottom-right part of the screen. [SUPER] + [ESC] – move window to center – but without fullscreen.

Shortcuts – Mouse

[Scroll Up] on Desktop – previous virtual desktop.

– previous virtual desktop. [Scroll Down] on Desktop – next virtual desktop.

– next virtual desktop. [Scroll Up] on (unshaded) Window Titlebar – shade current window.

– shade current window. [Scroll Up] on (shaded) Window Titlebar – unshade current window.

– unshade current window. [Middle Click] on Window Titlebar – send window to background.

– send window to background. [Right Click] on Window Titlebar – show window options menu (client menu).

– show window options menu (client menu). [Left Click] on Window Titlebar Icon – show window options menu (client menu).

– show window options menu (client menu). [Middle Click] on Window Titlebar Icon – close window.

Shortcuts – Various

[CTRL] + [SHIFT] + [ESC] – launch xterm(1) with htop(1) started with doas(1) for root provilages.

– launch with started with for root provilages. [SUPER] + [E] – start Explorer Caja primary file manager.

– start Caja primary file manager. [SUPER] + [E] – start Thunar secondary file manager.

– start Thunar secondary file manager. [SUPER] + [D] – show desktop – minimize all windows.

– show desktop – minimize all windows. [SUPER] + [R] – launch dmenu(1) starter.

– launch starter. [SUPER] + [L] – lock the screen.

– lock the screen. [ALT] + [SHIFT] + [SUPER] + [L] – lock the screen and go to sleep.

– lock the screen and go to sleep. [CTRL] + [PrintScreen] – make screenshot of the whole screen.

– make screenshot of the whole screen. [SHIFT] + [CTRL] + [PrintScreen] – make screenshot of current window (click without moving the mouse) or selection (select part of the screen).

Shortcuts – Volume

These two work from keyboard.

[SUPER] + [ALT] + [PageUp] – increase volume.

– increase volume. [SUPER] + [ALT] + [PageDown] – decrease volume.

These below with mouse.

For those who do not have mouse with buttons on the wheel like the Lenovo ThinkPad Precision Wireless Mouse (0B47163) for example, use [ALT] key with mouse scroll up/scroll down on the desktop to increase/decrease volume.

If you do have such mouse, then left on the wheel to decrease and right on the wheel to increase volume.

Random Wallpaper

The random wallpaper handling is done with the ~/scripts/random_wallpaper.sh script. Be sure to put some images into the ~/gfx/wallpapers directory to make it work and to configure crontab(1) properly as shown earlier.

Random xterm(1) Theme

To have random xterm(1) theme on every startup you need three things, the ~/.Xdefaults default config file which is used by xterm(1) , the ~/scripts/xterm.sh script and the ~/.config/Xdefaults directory with xterm(1) themes. I gathered all these themes all over the Internet, only the VERMADEN and VERMADEN-OLD themes are created by me.

Little preview of some of the included xterm(1) themes.

To make xterm(1) icon look better you will also need icons.tar.gz file download and extract with the end result looking as follows.

% find .icons .icons/vermaden/xterm.xpm

Download and extract the xterm.tar.gz file to make its contents look like that.

% find .Xdefaults .config/Xdefaults .config/Xdefaults .config/Xdefaults/Xdefaults.theme.3024NIGHT .config/Xdefaults/Xdefaults.theme.ALIENBLOOD .config/Xdefaults/Xdefaults.theme.ARTHUR .config/Xdefaults/Xdefaults.theme.EARTHSONG .config/Xdefaults/Xdefaults.theme.ELEMENTAL .config/Xdefaults/Xdefaults.theme.ELEMENTARY .config/Xdefaults/Xdefaults.theme.ELIC .config/Xdefaults/Xdefaults.theme.FLATUI .config/Xdefaults/Xdefaults.theme.FREYA .config/Xdefaults/Xdefaults.theme.FRONTEND-DELIGHT .config/Xdefaults/Xdefaults.theme.GITHUB .config/Xdefaults/Xdefaults.theme.GREY .config/Xdefaults/Xdefaults.theme.GRUVBOX-DARK .config/Xdefaults/Xdefaults.theme.GRUVBOX-LIGHT .config/Xdefaults/Xdefaults.theme.GRUVBOX-TILIX .config/Xdefaults/Xdefaults.theme.HARPER .config/Xdefaults/Xdefaults.theme.HEMISU-LIGHT .config/Xdefaults/Xdefaults.theme.HIGHWAY .config/Xdefaults/Xdefaults.theme.IC-GREEN-PPL .config/Xdefaults/Xdefaults.theme.MOLOKAI .config/Xdefaults/Xdefaults.theme.MONOKAI-SODA .config/Xdefaults/Xdefaults.theme.N0TCH2K .config/Xdefaults/Xdefaults.theme.NEOPOLITAN .config/Xdefaults/Xdefaults.theme.PALI .config/Xdefaults/Xdefaults.theme.PAPERCOLOUR .config/Xdefaults/Xdefaults.theme.SOLARIZED .config/Xdefaults/Xdefaults.theme.SOLARIZED-LIGHT .config/Xdefaults/Xdefaults.theme.SPACEDUST .config/Xdefaults/Xdefaults.theme.TOMORROW .config/Xdefaults/Xdefaults.theme.TWILIGHT .config/Xdefaults/Xdefaults.theme.VERMADEN .config/Xdefaults/Xdefaults.theme.VERMADEN-OLD

Thats a lot of information for one article, feel free to ask me for anything related or about things that I might forgot to put here.

UPDATE 1 – network.sh Integration

In other article I described how to manage various network sources with the network.sh script – FreeBSD Network Management with network.sh Script – available here.

Below is an example of integration of that network.sh script with Openbox window manager.

… and here is the code used in the ~/.config/openbox/menu.xml file.

Of course you can integrate network.sh script with almost anything – its just a command 🙂

EOF