Rendez-vous sur Arrakiss
Le 08/10/2019 à 15:14 dans /Logiciel-libre/OpenBSD/

A great desktop experience on OpenBSD with fluxbox

The story

My wife use debian for a long time. Since the last upgrade to debian buster, she was complaining because it was slow. I decided to install OpenBSD instead, and she seems happy with it.

Screenshots

great desktop experience openbsd fluxbox 1

great desktop experience openbsd fluxbox 2

Setup

Installation

OpenBSD is easy to install. I choosed to encrypt the whole system (and you probably should too)…

Xenodm

The login manager is xenodm. I enabled autologin since there is only one user :

   # rcctl enable xenodm
   # echo 'DisplayManager._0.autoLogin: user' >> /etc/X11/xenodm/xenodm-config

Installed packages

GraphicsMagick
cups
cups-filters-*
cups-libs
curl
dmenu
ffmpeg
foomatic-db
ghostscript-fonts
gimp
gnome-themes-standard
gtk+2-cups
gtk+3-cups
gtk+4-cups
gtk-engines2
gutenprint
hotplug-diskmount
firefox-esr
firefox-esr-i18n-fr
fluxbox
libdvdcss
libdvdnav
libdvdread
liberation-fonts
libreoffice
libreoffice-i18n-fr
lynx
vlc
evince-*-light
noto-emoji
noto-fonts
ntfs_3g
numlockx
optipng
p7zip
pcmanfm
roboto-fonts
leafpad
sct
gnome-colors-icon-theme
xclip
viewnior
xdg-user-dirs
xdg-utils
xdotool
youtube-dl
thunderbird
thunderbird-i18n-fr
arandr
dunst
rsync
xarchiver

Fluxbox configuration

Style

The style is called ion, available here. It is fine with Adwaita default gtk theme, the only really working one.

Bar

The menu can be called by clicking on the left arrow of the bar. In ~/.fluxbox/init :

session.screen0.toolbar.tools:  RootMenu, iconbar, systemtray, ,prevworkspace, workspacename, nextworkspace, clock
session.screen0.workspaceNames: # 1,# 2,# 3,# 4
session.screen0.strftimeFormat: %d/%m - %H:%M

Sound volume

Scrolling on the toolbar or the desktop change volume. It is also possible to change it in the menu. Here is the shortcut in ~/.fluxbox/keys

XF86AudioRaiseVolume :Exec mixerctl outputs.master=+10
XF86AudioLowerVolume :Exec muxerctl outputs.master=-10
XF86AudioMute :Exec mixerctl outputs.master.mute=toggle
# volume on bar and desktop
XF86AudioRaiseVolume :Exec mixerctl outputs.master=+10
XF86AudioRaiseVolume :Exec mixerctl outputs.master=+10
XF86AudioLowerVolume :Exec muxerctl outputs.master=-10
XF86AudioMute :Exec mixerctl outputs.master.mute=toggle

The menu

The most important part, the menu show small icons. Only useful things are available. Here is the ~/.fluxbox/menu :

[begin] (· MENU ·)
[encoding] {UTF-8}
[exec] (Navigateur web) {firefox-esr} </usr/local/share/icons/gnome-colors-common/16x16/emblems/emblem-web.png>
[exec] (Courriel) {thunderbird} </usr/local/share/icons/gnome-colors-common/16x16/apps/stock_mail.png>
[exec] (Capture d'écran) {scrotncopy} </usr/local/share/icons/gnome-colors-common/16x16/devices/gnome-screenshot.png>
[submenu] (Fichiers) {Fichiers} </usr/local/share/icons/gnome-brave/16x16/places/folder.png>
    [exec] (Gestionnaire de fichiers) {pcmanfm} </usr/local/share/icons/gnome-brave/16x16/apps/pcmanfm.png>
    [exec] (Dossier personnel) {pcmanfm} </usr/local/share/icons/gnome-brave/16x16/places/folder_home.png>
    [exec] (Cours) {pcmanfm ~/Cours} </usr/local/share/icons/gnome-brave/16x16/places/folder.png>
    [exec] (Classe) {pcmanfm ~/Classe} </usr/local/share/icons/gnome-brave/16x16/places/folder.png>
    [exec] (Recherche de fichiers) {pcmanfm -f} </usr/local/share/icons/gnome-brave/16x16/places/folder-saved-search.png>
    [exec] (MEDIAS) {pcmanfm /vol} </usr/local/share/icons/gnome-brave/16x16/places/stock_folder.png>
[end]
[separator]
[exec] (Bureautique) {libreoffice} </usr/local/share/icons/hicolor/16x16/apps/libreoffice-startcenter.png>
[exec] (Texte) {lowriter} </usr/local/share/icons/hicolor/16x16/apps/libreoffice-writer.png>
[exec] (Présentation) {loimpress} </usr/local/share/icons/hicolor/16x16/apps/libreoffice-impress.png>
[exec] (Tableur) {localc} </usr/local/share/icons/hicolor/16x16/apps/libreoffice-calc.png>
[exec] (Gimp) {gimp} </usr/local/share/icons/hicolor/16x16/apps/gimp.png>
[exec] (Éditeur de texte) {leafpad} </usr/local/share/icons/hicolor/16x16/apps/leafpad.png>
[exec] (VLC) {vlc} </usr/local/share/icons/gnome-colors-common/16x16/apps/vlc.png>
[separator]
[submenu] (Volume) </usr/local/share/icons/gnome-brave/16x16/status/stock_volume.png>
        [exec] (0%) {setvol 0}
        [exec] (10%) {setvol 10}
        [exec] (20%) {setvol 20}
        [exec] (30%) {setvol 30}
        [exec] (40%) {setvol 40}
        [exec] (50%) {setvol 50}
        [exec] (60%) {setvol 60}
        [exec] (70%) {setvol 70}
        [exec] (80%) {setvol 80}
        [exec] (90%) {setvol 90}
        [exec] (100%) {setvol 100}
[end]
[submenu] (Température d'écran) </usr/local/share/icons/gnome-colors-common/16x16/apps/preferences-desktop-wallpaper.png>
        [exec] (Mars) {sct 2000}
        [exec] (Feu de camp) {sct 4500}
        [exec] (Normal) {sct}
        [exec] (Café) {sct 8000}
[end]
[exec] (Résolution d'écran) {arandr} </usr/local/share/icons/gnome-colors-common/16x16/apps/preferences-desktop-screensaver.png>
[separator]
[submenu] (Session) </usr/local/share/icons/gnome-colors-common/16x16/apps/gnome-session-properties.png>
    [submenu] (Configurer)
        [exec] (Changer le thème GTK) {lxappearance}
        [submenu] (System Styles) {Choose a style...}
            [stylesdir] (/usr/local/share/fluxbox/styles)
        [end]
        [config] (Configuration Fluxbox)
        [submenu] (User Styles) {Choose a style...}
            [stylesdir] (~/.fluxbox/styles)
        [end]
        [reconfig] (Recharger la configuration)
    [end]
    [separator]
    [exec] (Verouiller l'écran) {xlock} </usr/local/share/icons/gnome-colors-common/16x16/actions/system-lock-screen.png>
    [exit] (Fermer la session) </usr/local/share/icons/gnome-colors-common/16x16/actions/gnome-session-logout.png>
    [separator]
    [exec] (Suspendre) {doas /usr/sbin/apm -S} </usr/local/share/icons/gnome-colors-common/16x16/actions/system-lock-screen.png>
    [exec] (Hiberner) {doas /usr/sbin/apm -z} </usr/local/share/icons/gnome-colors-common/16x16/apps/gnome-session-sleep.png>
    [exec] (Redémarrer) {doas /sbin/reboot} </usr/local/share/icons/gnome-colors-common/16x16/apps/gnome-session-reboot.png>
    [exec] (Éteindre) {doas /sbin/shutdown -hp now} </usr/local/share/icons/gnome-colors-common/16x16/apps/gnome-session-halt.png>
[end]
[endencoding]
[end]

A few notes about the menu.

The screenshot let select a part of the screen and copy the screenshot to clipboard to paste in libreoffice then. The script requires Graphicsmagick and xclip : scrotncopy.

The menu “volume” call setvol :

#!/bin/sh
# set volume to percent
vol=$(( $1 * 255 / 100 ))
mixerctl outputs.master=${vol}
exit

Tu reboot/shutdown the system, doas must be configured in /etc/doas.conf :

echo "permit persist :wheel " >> /etc/doas.conf
echo "permit nopass :wheel cmd /sbin/shutdown" >> /etc/doas.conf
echo "permit nopass :wheel cmd /sbin/reboot" >> /etc/doas.conf
echo "permit nopass :wheel cmd /usr/sbin/apm" >> /etc/doas.conf

Session

In ~/.xsession :

# translations and environment
. ~/.profile
# dbus
if [ -x /usr/local/bin/dbus-launch -a -z "${DBUS_SESSION_BUS_ADDRESS}" ]; then
    eval `dbus-launch --sh-syntax --exit-with-x11` &
fi
# Load X options
xrdb -merge ~/.Xresources &
# disable bell
xset b off &
# numpad
numlockx &
# notification
dunst &
# take care of you eyes, change temperature color
sct 5000 1>/dev/null &
# desktop
pcmanfm --desktop &

startfluxbox

Various

softdeps

Speed up the disk

sed -i 's/rw,/rw,softdep,/g' /etc/fstab

unwind and adblock

rcctl enable unwind
touch /var/unwind.block
echo 'block list "/var/unwind.block"' > /etc/unwind.conf
ftp -o /usr/local/sbin/unwind-block https://dev.ybad.name/OpenBSD-stuff/unwind-block
chmod +x /usr/local/sbin/unwind-block
echo 'prepend domain-name-servers 127.0.0.1;' >> /etc/dhclient.conf
# or
echo 'nameserver 127.0.0.1' > /etc/resolv.conf
echo 'lookup file bind' >> /etc/resolv.conf

In /etc/rc.local :

DAYS=7
if [ -n "$(find /var/unwind.block -mtime +${DAYS} )" ]; then
    /usr/local/sbin/unwind-block > /var/unwind.block &
fi

ntpd

rcctl enable ntpd
sed -i 's/www\.google\.com/www.openbsd.org/' /etc/ntpd.conf

hotplug

Every media such as usb stick will be mounted in /vol.

/usr/local/libexec/hotplug-diskmount init
chmod +x /etc/hotplug/{attach,detach}
rcctl enable hotplugd

/etc/hotplug/attach :

#!/bin/sh

DEVCLASS=${1}
DEVNAME=${2}

case "${DEVCLASS}" in
        0)
            if [ -n "$(echo $DEVNAME | grep -o "ugen[0-9]")" ]; then
                addr=$(dmesg | grep $DEVNAME | \
                    tail -n1 | \
                    cut -d' ' -f3 | \
                    tr -d '[:alpha:]' \
                    )
                chown _cups /dev/${DEVNAME}.* /dev/usb$addr
            fi
        ;;

        2)
            /usr/local/libexec/hotplug-diskmount attach -f dirty -m 0777 "${DEVNAME}"
        ;;
esac

/etc/hotplug/detach :

#!/bin/sh

DEVCLASS=$1
DEVNAME=$2

case $DEVCLASS in
        2)
                /sbin/umount "/mnt/$DEVNAME"
        ;;
esac
exit 0

cups

Since we have a USB printer, we must disable ulpt :

# cat rc.shutdown 
echo "* Disable ulpt to use USB printers"
printf 'disable ulpt\nq\n' | config -ef /bsd
echo "* Recompute sha256 sum"
sha256 /bsd >/var/db/kernel.SHA256

Locale

We are french, so in ~/.profile :

LC_CTYPE="fr_FR.UTF-8"
LC_MESSAGES="fr_FR.UTF-8"
LC_COLLATE=fr_FR.UTF-8
LC_ALL='fr_FR.UTF-8'
LANG='fr_FR.UTF-8'

export LC_COLLATE LC_CTYPE LC_MESSAGES LC_ALL LANG