#!/bin/bash # by Benjamin Okopnik # A random background selector for XFree86 PIC_DIR=/usr/share/Eterm/pix TMPFILE=$(mktemp /tmp/temp.XXXXXX) ls $PIC_DIR/* > $TMPFILE 2> /dev/null RNDM=$(($RANDOM/65534)) fnm=$(sed -n $(($RNDM * $(grep -c $ $TMPFILE) / 32767 + 1))p $TMPFILE) [ -f $PIC_DIR/$1 ] && fnm=$PIC_DIR/$1 echo -n "Using " basename $fnm X="`ps ax`" while [ `echo $X|grep -c icewm` -lt 1 ] do X="`ps ax`" sleep 1 done sleep 1 fn=$(basename $fnm) [ -z ${fn%%[A-Z]*} ] && max="-max" xv -root -quit $max $fnm # Clean up... rm $TMPFILE