First I'll detail my script, but be sure to continue to read further down as a better solution exists!
I initially created a script for GNOME that I was able to point to a directory full of images and have it randomly display a picture from the directory of images as my background. I then created a cronjob to execute the script so about every couple hours I would have a new backgroup.
NOTE: This will only work in GNOME 2.x as the script utilizes gconftool-2. I'm sure it can be modified to work with other versions of GNOME as well.
- Create the script!
- vi chgBackground.sh
- #!/bin/sh
PID=$$
PHOTO_DIR=$1
if [[ -z ${PHOTO_DIR} ]]; then
echo "You must specify a directory that has your photos."
exit 1
fi
if [[ ! -d ${PHOTO_DIR} ]]; then
echo "Directory '${PHOTO_DIR}' does not exist."
exit 1
fi
# Look for files with extension .jpg or .png
PIC_COUNT="`find ${PHOTO_DIR} -iregex ".*\.\(jpg\|png\)$" | wc -l`"
if [[ ${PIC_COUNT} -eq 0 ]]; then
echo "No pictures found!"
exit 1
fi
find ${PHOTO_DIR} -iregex ".*\.\(jpg\|png\)$" > /tmp/chgBackground.${PID}
RANDOM=${PID}
RAN_VAR=`echo $[(${RANDOM} % ${PIC_COUNT}) + 1]`
BKG_PATH=`head -${RAN_VAR} /tmp/chgBackground.${PID} | tail -1`
/opt/gnome/bin/gconftool-2 -t string -s /desktop/gnome/background/picture_filename ${BKG_PATH}
rm -f /tmp/chgBackground.${PID}
- vi chgBackground.sh
- Set perms to execute the script
- chmod +x chgBackground.sh
- Run the script!
- chgBackground.sh /path/to/pics
- Schedule in crontab to run automatically
- crontab -e
- Add the following to change every hour:
- 0 * * * * sh -x /path/to/script/chgBackground.sh > /dev/null
- Download xwinwrap from http://tech.shantanugoel.com/projects/linux/shantz-xwinwrap
- unzip the downloaded file
- /path/to/xwinwrap -fs -st -sp -b -ov -- /usr/lib64/xscreensaver/glslideshow -window-id WID -duration 8 -pan 8 -fade 2 &
- -fs : parameter for xwinwrap to run fullscreen
- -st and -sp : I set these so that when xwinwrap runs it does not show up with a program window in the "Workspace Switcher" applet
- -b : This has xwinwrap run below GNOME panels
- -ov : This allows xwinwrap to run in all virtual desktops
- -- /usr/lib64/xscreensaver/glslideshow -window-id WID -duration 8 -pan 8 -fade 2 : This is an argument passwed to xwinwrap of the command you pass to xwinwrap to be run over your desktop
- -window-id WID : parameter for glslideshow to run fullscreen in your GNOME window
- -duration 8 : parameter for glslideshow on how long to have a single photo displayed
- -pan 8 : how long to pan the image for (if less then duration it will pan the image over 2 cycles for same image)
- -fade 2 : parameter for glslideshow on how to to fade between images
- & : allows xwinwrap to run in the background
- vi ~/.xscreensaver
- edit/add the line containing "imageDirectory" to point to the directory of images
- EXAMPLE:
imageDirectory: /path/to/images
- EXAMPLE:
- edit/add the line containing "imageDirectory" to point to the directory of images