Archive for July, 2012

Simple script for changing wallpaper using RSS feed

Monday, July 16th, 2012

Just had the idea to change the wallpaper of my desk according to an RSS feed.

Here’s the shellscript:

#!/bin/sh
 
IMGPATH="/home/chris/Pictures/Wallpapers/factsandchicks"
IMGURL=$(wget -q -O- "http://www.factsandchicks.com/rss" | grep -o 'src="[^"]*' | grep -m 1 -o '[^"]*$')
LOCALFILENAME=$(echo $IMGPATH/$(date +"%Y%m%d").jpg)
 
wget -q -O$LOCALFILENAME $IMGURL
 
gsettings set org.gnome.desktop.background picture-uri file:///$LOCALFILENAME

For this example, I used the RSS feed from factsandchicks.com (o.O)
The command in the last line depends on your distribution, this one works for newer Ubuntus. You probably want to run this script via cron or rc.local to get the new wallpapers regularly.

Have fun!