NetBSD desktop pt.4: The X Display Manager (XDM)


I’m among those who actually like using a Display Manager on *nix and XDM has always represented my gold standard; while it may not support xft, GTK/Qt themes, and other eye-candy hacks which things like GDM, SDDM, and LightDM may have, it’s extremely low on resources, quite easy to customize, included in base, and most of all, it just works.
XDM is the oldest DM ever made (1988), and has been forked several times since its birth: Wings (WindowMaker), dtlogin (CDE), mlogind (MidnightBSD), Xenodm (OpenBSD) come to mind.

Providing I find default XDM config quite unpleasant from both an aesthetic and practical point of view, here I share my XDM set up hoping it will serve as sample and a starting point for others to use.

Aside from the login widget (xlogin), this setup includes a wallpaper, a clock, shutdown/reboot buttons, syslogd() messages onto the X root window. To achieve this, I tried to make use of the simplest tools possible, which are respectively:

[1]Note: if you use feh, hsetroot, qiv or others to set your wall already, you can default those and edit Xsetup_0 below accordingly


# here's the Xlib resources which XDM will read
xlogin*login.translations: #override \
	Ctrl<Key>R: abort-display()\n\
	<Key>F1: set-session-argument(failsafe) finish-field()\n\
	<Key>Delete: delete-character()\n\
	<Key>Left: move-backward-character()\n\
	<Key>Right: move-forward-character()\n\
	<Key>Home: move-to-begining()\n\
	<Key>End: move-to-end()\n\
	Ctrl<Key>KP_Enter: set-session-argument(failsafe) finish-field()\n\
	<Key>KP_Enter: set-session-argument() finish-field()\n\
	Ctrl<Key>Return: set-session-argument(failsafe) finish-field()\n\
	<Key>Return: set-session-argument() finish-field()

xlogin*greetFont: -*-lucida-bold-r-normal-*-24-*-*-*-p-*-iso8859-1
xlogin*font: -*-lucida-medium-r-normal-*-14-*-*-*-p-*-iso8859-1
xlogin*promptFont: -*-lucida-bold-r-normal-*-14-*-*-*-p-*-iso8859-1
xlogin*failFont: -*-lucida-bold-r-normal-*-14-*-*-*-p-*-iso8859-1
xlogin*greetFace:   Lucida-24
xlogin*face:        Lucida-14
xlogin*promptFace:  Lucida-14:bold
xlogin*failFace:    Lucida-14:bold

#ifdef COLOR

xlogin*borderWidth: 0
xlogin*frameWidth: 0
xlogin*innerFramesWidth: 1
xlogin*shdColor: black
xlogin*hiColor: black
xlogin*background: black
xlogin*foreground: White
xlogin*promptColor: #FF8747
xlogin*greetColor: #FF8747
xlogin*failColor: yellow

*Foreground: #FF8747
*Background: Black


xlogin*borderWidth: 3
xlogin*frameWidth: 0
xlogin*innerFramesWidth: 1
xlogin*shdColor: black
xlogin*hiColor: black


xlogin*useShape: false
xlogin*logoPadding: 10
xlogin*geometry: +100+100

xlogin*greeting: Welcome to NetBSD Unix
xlogin*fail: sorry, maybe next time...

xlogin*namePrompt: username:  
xlogin*passwdPrompt: password:  

xmessage*geometry: 160x32+0+0
xmessage*font: -*-lucida-bold-r-normal-*-12-*-*-*-p-*-iso8859-1

xclock*font: -*-lucida-medium-r-normal-*-12-*-*-*-p-*-iso8859-1
xclock*update: 1
xclock*padding: 4
xclock*geometry: -10+0


# XDM shall execute this script at runtime


PATH=$PATH:/usr/pkg/bin; export PATH
xclock &  
xli -onroot -quiet -fullscreen /etc/X11/xdm/netbsd-orange.jpg
root-tail -f -color "#FF8747" -geometry 380x24+10+450 -fn -*-lucida-medium-r-normal-*-12-*-*-*-p-*-iso8859-1 /var/log/messages 

xmessage -buttons Shutdown:1,Reboot:2 "" ;
case $? in
 exec /sbin/poweroff;;
 exec /sbin/reboot;;
 echo "XDM closed on `date`";;


#This script is executed after login. Use it to clean desktop and \ 
# kill any XDM child process owned by root.
# XDM shall then drop ownership of /dev/console for $user to pick

USER="your username here"; export USER
pkill xli
pkill xconsole
pkill root-tail
pkill xclock
pkill xmessage
chown $USER:wheel /dev/console

enable UTF-8 support for the X session

echo "export LANG=\"en_US.UTF-8\"" > ~/.xsession
echo "export LC_CTYPE=\"en_US.UTF-8\"" >> ~/.xsession

export your X startup script for XDM to read

cat ~/.xinitrc >>  ~/.xsession 

enable XDM

echo "xdm=YES" >> /etc/rc.conf
service xdm start

(Optional) get a screenshot of your custom layout

This will save a temporary .png screenshot of your XDM diplay at each session on volatile memory. The shot() script makes use of xwd (in base), and graphics/ImageMagick

mkdir /root/bin

cat > /root/bin/shot << EOF
> #!/bin/sh
> PATH=$PATH:/usr/pkg/bin; export PATH
> raw="/tmp/xdm.xwd"
> shot="/tmp/xdm.png"
> sleep 10
> xwd -root -out $raw
> if [ -e $raw ] 
>    then convert $raw $shot
> fi

chmod +x /root/bin/shot
echo "/root/bin/shot &" /etc/X11/xdm/Xsetup_0 

The result looks like the following

Wallpaper was created by me on GIMP, you can get it this way: