LinkedIn Sourceforge Twitter

Vincent's Blog

Pleasure in the job puts perfection in the work (Aristote)

update version of xenodm loginscreen

Posted on 2019-07-20 08:54:00 from Vincent in OpenBSD Desktop

After my blog on xenodm, I've received several interesting remarks. So, this blog is to integrate some of those remarks (not all) and to include a nice looking dynamic picture.

After my previous post concerning xenodm, I'have received some interesting remarks. I will integrate several of them.

Coding improvements

As suggested by rcj:

  • I've used the ksh pattern substitution.
  • Concerning simplified "if", I'm not a fan of it.
  • It's indeed safer to use the "-qx" flag for pgrep.
  • Concerning the setxkbmap, I prefer to use "-print" instead of "-query" because it provide both layout and variant.

The new script (/etc/X11/xenodm/Xsetup_0) becomes this:


/usr/X11R6/bin/xrandr --output default --dpi 96

# requires pkg_add terminus-font
/usr/X11R6/bin/xset fp+ /usr/local/share/fonts/terminus

# set background color
/usr/X11R6/bin/xsetroot -solid $BG_COLOR

SIZES=$(/usr/X11R6/bin/xrandr | /usr/bin/awk ' /\*/ { print $1}' )
POSY=$(( $HEIGHT * 5 / 100 ))  # 5% free space from top
PUFFY_WIDTH=$(( 700 - 2 * $POSY ))  #700 is xlogin.Login.y coming from the Xresouces file
POSX=$(( ( $WIDTH - $PUFFY_WIDTH ) / 2 ))

if [ ! -f $PICTURE_FILE ]; then
   cp /etc/X11/xenodm/pixmaps/bluepuffy.jpg $PICTURE_FILE
chmod 666 $PICTURE_FILE

# show BluePuffy 
/usr/local/bin/feh -B$BG_COLOR -g${PUFFY_WIDTH}x${PUFFY_WIDTH}+$POSX+$POSY -. -Z "$PICTURE_FILE" &

# show the Sleep / Restart / Shutdown bar
# in case of sleep, pop xmessage again after waking up
while true; do
  #to position the text at the middle of the screen
  POS=$(( ( $WIDTH - 12*34 ) / 2  ))  #text is 34 char, 12 is linked to the size of font select in Xresources
  /usr/X11R6/bin/xmessage -geometry +$POS-150         -buttons "[ Sleep ]":20,"[ Restart ]":21,"[ Shutdown ]":22 ""
  echo "Xmessage said: $ACTION"
  if   [ $ACTION -eq 20 ]; then /usr/sbin/zzz
  elif [ $ACTION -eq 21 ]; then
    /usr/X11R6/bin/xsetroot -cursor_name watch
    /sbin/shutdown -r now
  elif [ $ACTION -eq 22 ]; then
    /usr/X11R6/bin/xsetroot -cursor_name watch
    /sbin/shutdown -p now
  else echo "Something bad happened to Xmessage."
  # stop looping if xclock died (hopefully killed by GiveConsole)
  if [ -z "$(/usr/bin/pgrep -qx -U root xclock)" ]; then break; fi
) &

OS_NAME=$(/usr/bin/uname -n)
OS_INFO=$(/usr/bin/uname -smr)
KEYBD=$(/usr/X11R6/bin/setxkbmap -print | grep xkb_symbols | cut -d"+" -f2)

/usr/X11R6/bin/xclock -geometry -0+20       -strftime "$OS_NAME ($OS_INFO) Keyboard: $KEYBD | %a. %d %b. %Y  %H:%M:%S " &

I remind that you need the "feh" package (doas pkg_add feh). And other files remains unchanged.

Dynamic picture

Thanks to a small script written by Thuban (here), we can get a nice picture of the day on xenodm login screen.

My slightly adapted version is this:

# original author: Thuban <>
# license: MIT

URL=$(/usr/bin/ftp -w 3 -o - '' | /usr/bin/grep -o 'src="http[^"]*"'| grep -E "\.(jpg|jpeg)" | /usr/bin/cut -d" -f2 | /usr/bin/head -n1)
if [ $URL ]; then
    ftp -o /tmp/xenodm.jpg "$URL"

(I call this file "")

In short, this script get the last "Bonjour Madame" picture of the day and put it in /tmp/xenodm.jpg in place of the BluePuffy picture.

So, at the first login, you will get the nice BluePuffy picture. But after having executed this script, you will get an other picture.


Thanks to my vdcron utility (a cron for laptops/desktops), I'm able to trigger once per day. For that I'm just adding the following line in my ~/.vdcron/vdcron.conf file:

+20190721/1 /home/vi/bin/

Since vdcron is triggered by my .profile file, I'm sure to have a new picture each day ;-).

Some samples

Examples of last 2 days:

19, 17
displayed: 6985

What is the second letter of the word Moon?