just an itch I needed to scratch; there's an image on a website, and it is updated every day (happily using a regular format for its url). I want to fetch this image every day and set it as my desktop background. In my example, the image is the YouGov daily poll ratings for the UK, but I hope this will be helpful for others to adapt.
A quick run-through:
date +%d --date="yesterday" > date
echo http://today.yougov.co.uk/sites/today.yougov.co.uk/files/550pxVotIntdategoeshere1010.jpg > templateurl
cat templateurl | sed "s/dategoeshere/`cat date`/" templateurl > url
wget $( cat "./url" ) -O today.png
gconftool-2 --type string --set /desktop/gnome/background/picture_filename "$HOME/pollgrabber/today.png"
gconftool-2 --type string --set /desktop/gnome/background/picture_options centre
- Make a directory for the script to run in, just makes things tidier. Don't worry about running this again, if the folder's already there it doesn't matter.
- Change to that directory
- Find yesterday's date, i.e. if yesterday was 21st October, a file will be created containing the text 21.
- This url will be set as the template for the date to be substituted into
- Substitute the "date" file into the template url
- Use wget (a downloading tool) to fetch the image
- Use gconftool to set the image as the wallpaper
- Use gconftool to centre the wallpaper (optional, but probably a good idea with medium-low res images like this one)
Hope someone finds this useful.