#!/bin/bash # # chxbg - Set X background from command line or random (my files) # # Where to get the selection of images: #bgdir="/usr/local/Propaganda/" bgdir="/usr/local/GimpFoolery/" # Where to store the image in xpm format for rxvt: rxvtFile="$HOME/bin/rxvt.xpm" tmpfile="/tmp/$(basename ${0}).$$.txt" if [ ! ${DISPLAY} ] then echo "This program requires X, which doesn't appear to be running." exit 1 fi if [ -f "${1}" ] then bgName="${1}" else find ${bgdir} -name "*.jpg" -print | grep -v \.xvpics > ${tmpfile} find ${bgdir} -name "*.png" -print | grep -v \.xvpics >> ${tmpfile} numbgs="$(cat $tmpfile | wc -l)" randbg="$(echo -e "scale=0 \n${numbgs}*${RANDOM}/32767 \nquit" | bc)" bgName="$(echo "$(cat ${tmpfile} | awk 'NR=='${randbg}' {print $0}')")" rm ${tmpfile} fi #if which Esetroot 2> /dev/null >/dev/null #then # Same effect as display, but makes Eterm work much better: #Esetroot ${bgName} #else #display -window root ${bgName} #xv -root ${bgName} & sleep 1 && killall xv #wmsetbg --tile ${bgName} fbsetbg -t ${bgName} #fi # Make an xpm of the image with reduced brightness and saturation for # rxvt (requires ImageMagick): #convert -modulate 60,70 ${bgName} ${rxvtFile} convert -colorize 75,75,75 ${bgName} ${rxvtFile}