Monday, December 20, 2010

XKCD on your GNOME background


I wrote this little script which would download the latest XKCD comic and put it centred onto your GNOME Wallpaper.

It screenscraps the latest XKCD homepage and looks for the image URL, it then downloads it to /tmp and uses gconftool-2 to set it as your background.

Try it out and lemme know if you like it.

I have put a cron like
0 15 * * mon,wed,fri /path/to/
That will update my wallpaper at 3 p.m every Monday, Wednesday and Friday.

* Would like to make it Desktop independent.
* Would like to have the mouseover text below the comic.

Thanks to andy(see comments) this script uses JSON to get the data, and avoid screenscraping.


Anonymous said...

To save you scraping the HTML data, is the JSON interface useful to you?

$hRiNk said...

Very. Thanks. Didn't know this existed.
Updating blog with the json code.

Keiran said...

* Would like to make it Desktop independent.
- This can be done using an if statement pretty easily. So you could add an argument like gnome and it would set the gnome background

* Would like to have the mouseover text below the comic.
- This can be easily achieved by grabbing the page for the comic and using regex to grab the alt="" text from the source document

$hRiNk said...

I was thinking more terms of a desktop independent command. gconftool-2 is gnome specific.
Also getting the text is not that much an issue as getting it displayed as a caption on the image.

vinzv said...

Why not use imagemagick? Something like should do the job...

$hRiNk said...

Thanks vinzv.
But I was trying to avoid shell-scripting.

I used the python Image module and this is what I have now:

Saeed Zia said...

Latest Hot Entertainment News, Latest update about Bollywood, hollywood, pakistani Girls