This is a little bash script I wrote to fetch the latest Sinfest webcomic and places it on my Gnome desktop. It also formats the image to scale on Sundays using ImageMagick.
UPDATE: as of 7 December 2009 this script is licensed GNU/GPL v2
#!/bin/bash # fetch latest sinfest # set as gnome desktop # Copyright Jeff Channell 2009 # base url URL=`echo "http://www.sinfest.net/comikaze/comics/"` # name of file, based on date FILENAME=`echo "`date +%Y-%m-%d`.gif"` # where are we storing the images? FOLDER=/home/jeff/Comics/sinfest/ # full path of file LOCALFILE=`echo "$FOLDER$FILENAME"` # check if storage exists... file $FOLDER > /dev/null 2>&1 if [ $? -eq 1 ] then # no folder, try to create mkdir -p $FOLDER fi cd $FOLDER if [ $? -eq 1 ] then # still no folder, die exit 1 fi # go get the file wget -nc $URL$FILENAME > /dev/null 2>&1 # check file $LOCALFILE > /dev/null 2>&1 if [ $? -eq 0 ] then if [ `date +%a` == "Sun" ] then # bonus - resize file `which mogrify` > /dev/null 2>&1 if [ $? -eq 0 ] then mogrify -resize x970 "$LOCALFILE" fi fi # set background gconftool-2 --type string \\ --set /desktop/gnome/background/picture_filename "$LOCALFILE" gconftool-2 --type string \\ --set /desktop/gnome/background/picture_options "centered" fi exit 0
Then, to get it to run, I added this to my crontab:
0 */8 * * * /home/jeff/local/bin/desktop.bash > /dev/null 2>&1
UPDATE: I've been having some issues with cron not running lately as my user, but I also had Alarm Clock installed, so I just set a custom alarm to run my script there, and it's been working great ever since!