Monday, December 20, 2010

XKCD on your GNOME background

Hi,

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/xkcd.py
That will update my wallpaper at 3 p.m every Monday, Wednesday and Friday.

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

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

7 comments:

andy said...

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

http://xkcd.com/info.0.json

$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...

@Keiran
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 http://metashell.de/imagecaption 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:
https://github.com/shreyankg/xkcd-desktop/blob/master/xkcd.py

Saeed Zia said...

Latest Hot Entertainment News, Latest update about Bollywood, hollywood, pakistani Girls
hotentertainnews.blogspot.com