Customizing OpenBSD xenodm
789 words, 4 minutes
OpenBSD ships with a graphical login screen named xenodm. The default configuration looks a bit old (to my taste). So I decided to look at how to have it feel a bit more modern. Somebody said “ricing” ? …
The default look
By default, you get a yellow & blue xlogin widget, branded with Puffy. Plus, you get the xconsole application. To be honest, the first thing I always do is kill xconsole. If I want to check for errors, I’ll just go to the log files.
I guess you don’t get any background to limit bandwidth usage in case you’re
using XDMCP to remotely connect to OpenBSD. Although only localhost is enabled
by default.
Basic cleaning and coloring
First thing is to get rid of xconsole, add some extra widget, get a decent background and change the colors for the login widget.
I grabbed a ThinkPad picture on the Internet to create a specific palette. That’s where the black, grey and blue come from. The xconsole is removed by modifying /etc/X11/xenodm/Xsetup_0. In the same file, I also added an xsetroot command to setup the background color and an xclock command to show the date and time.
# $OpenBSD: Xsetup_0,v 1.5 2018/07/17 11:52:12 matthieu Exp $
xrandr --output default --dpi 96
xsetroot -solid $(xrdb -query | awk '/xroot.background/ { print $2 }')
xclock -strftime "%a. %d %b. %Y %H:%M " &
Finally, the /etc/X11/xenodm/Xresources file was modified to change color, fonts and geometry. Full diff it available here .
The Nordish look with more widgets
I decided to use the Nord colorscheme . The Puffy image was also changed using the stock Chix Dig artwork. The xclock application shows hostname with date and time. The xmessage application allows to shutdown, reboot or put the computer to sleep.
To start the (x)applications, the Xsetup_0 script has to be modified:
$OpenBSD: Xsetup_0,v 1.5 2018/07/17 11:52:12 matthieu Exp $
xrandr --output default --dpi 96
# requires pkg_add terminus-font
xset fp+ /usr/local/share/fonts/terminus
# set background color
BG_COLOR=$(xrdb -query | awk '/xroot.background/ { print $2 }')
xsetroot -solid $BG_COLOR
# show BluePuffy
/usr/local/bin/feh -B $BG_COLOR -g 192x192+584+144 -. \
-Z /etc/X11/xenodm/pixmaps/BluePuffy.png &
# show the Sleep / Restart / Shutdown bar
# in case of sleep, pop xmessage again after waking up
(
while true; do
xmessage -geometry +540-32 \
-buttons "[ Sleep ]":20,"[ Restart ]":21,"[ Shutdown ]":22 ""
ACTION=$?
echo "Xmessage said: $ACTION"
if [ $ACTION -eq 20 ]; then /usr/sbin/zzz;
elif [ $ACTION -eq 21 ]; then
xsetroot -cursor_name watch
/sbin/shutdown -r now
elif [ $ACTION -eq 22 ]; then
xsetroot -cursor_name watch
/sbin/shutdown -p now
else echo "Something bad happened to Xmessage.";
fi
# stop looping if xclock died (hopefully killed by GiveConsole)
if [ -z "$(pgrep -U root xclock)" ]; then break; fi
done
) &
OS_NAME=$(uname -n)
OS_INFO=$(uname -smr)
xclock -geometry -0+0 \
-strftime "$OS_NAME ($OS_INFO) | %a. %d %b. %Y %H:%M " &
When the user chooses “Sleep”, xmessage will terminate. The loop is used to have xmessage back again on computer resume. The background loop has to terminate when user has logged in. To do that, I use the xclock as a witness. Only xenodm uses it on my workstation. No more xclock means the user has authenticated. And the loop should stop. So far, xclock hasn’t died by it own while in xenodm.
The other trick in this configuration is to kill all the widgets when the authentication has succeed. If that’s not done, you’ll end up with an xclock and xmessage on your <Insert_You_Preferred_DE_Here>. This is done by modifying the GiveConsole script:
$OpenBSD: GiveConsole,v 1.2 2018/07/11 19:20:40 matthieu Exp $
#
pkill feh
pkill xclock
pkill xmessage
chown $USER /dev/console
(...)
Full diff for this configuration is available here .
The dark clean login screen
In the end, I decided to go dark and textfull. The colors are taken from a ThinkPad picture. And indeed, it looks great when displayed on my X230i.
It uses Xresources to color and place widgets. Action buttons are displayed using the same xmessage as in previous example. Date and time are displayed using two xclock instances in the Xsetup_0 script:
# show the date and time as two different widgets
for CLK in date time; do
FACE=$(echo "$XRES" | grep "xclock.${CLK}Face" | xargs | \
cut -d ' ' -f 2-)
GEOM=$(echo "$XRES" | grep "xclock.${CLK}Geom" | xargs | \
cut -d ' ' -f 2-)
STR=$(echo "$XRES" | grep "xclock.${CLK}Str" | xargs | \
cut -d ' ' -f 2-)
xclock -face "$FACE" -geometry "$GEOM" -strftime "$STR" &
done
The whole diff for this configuration is available here .
Special backlinks to Roman Zolotarev and Giulio Bottazzi . Those posts were great continuations after reading the manpage .