Download.Shirt.Woot.sh
From KCLUG Wiki
Run this by crontab, daily, to get a new image at ~/Pictures/Shirt.Woot/Current.png. Set your background to ~/Pictures/Shirt.Woot/Current.png, and at least in gnome, it should update on its own.
#!/bin/bash
HTMLURL="http://Shirt.Woot.com"
XMLURL="http://Shirt.Woot.com/blog/rss.aspx"
WhereToSave="${HOME}/Pictures/Shirt.Woot"
function ShowUsage {
echo "$0 - download shirt.Woot detailed images"
echo "USAGE: $0"
echo "Fetch the detailed shirt.woot image from Shirt.Woot's webpage at ${HTMLURL} and"
echo "save it to ${WhereToSave}/. Then update a link at ${WhereToSave}/Current.png to"
echo "point to the latest image."
echo ""
echo "NOTE:"
echo "(If you want to use this to get a fresh desktop background every day, you'll"
echo "want to use that link file as the background.)"
echo ""
echo "Arguments:"
echo "------------"
echo " --snarf Use the XML feed to get the last few days worth of images."
echo " --nocurrent Don\'t update the \"Current.png\" link."
exit 1
}
function Snarf {
mkdir ${WhereToSave}
cd ${WhereToSave}
#Search the XML to find the URLs of the detail pics, and download them.
curl -s "${XMLURL}" | grep -i media:content | grep -i detail | \
sed -e 's/\.png.*/\.png/' -e 's/.*http:/http:/' | \
while read URL
do
wget $URL
done
}
function Download {
mkdir -p ${WhereToSave}
cd ${WhereToSave}
#Search the HTML to find the URL of the salepic, and download it.
URL=`curl -s "${HTMLURL}" | grep -i salepic | sed -e 's/\.png.*/\.png/' -e 's/.*http:/http:/'`
wget ${URL}
}
function MakeCurrent {
#Find the most recent image.
MostRecent=`ls "${WhereToSave}/" -t | grep .png | grep -v Current.png | head -1`
#You must use cat to write over Current.png rather than replacing it with a new copy or link which would change the inode number, and break the desktop manager's file handle.
cat ${MostRecent} > "${WhereToSave}/Current.png"
}
case $1 in
--help* | help* | --usage* | usage*)
ShowUsage
;;
--snarf* | snarf*)
Snarf
;;
--nocurrent*)
Download
;;
*)
Download
MakeCurrent
;;
esac
exit 0

