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:

Anonymous 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 "Affix" Smith 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

Anonymous said...

iSprout Business Center is a home for inspiring workspaces created to match the needs of ever-growing business enterprises. From a single dedicated space for a freelancer to custom-made corners for established corporate, there is room for everyone. To name a few we offer private office spaces, coworking space in Hyderabad, single desks, virtual offices, conference rooms, everything with flexible plans which suit your pockets. Come join the hub of dreamers, workers and achievers! With a suite of amenities to offer, it just gets better!
Gone are the days when just any office space would do. Today, employee productivity & office ecosystem are greatly influenced by the functional and aesthetic standards of the workstation. office space for rent in hyderabad is here to redefine the art, science, and the future of “plug-n-play office space for rent in Hyderabad, Vijayawada and Chennai.”
office space in hyderabad
office space for startups in hyderabad
office space in vijayawada
private office space for rent
coworking space in chennai
coworking space in chennai
business centre in hyderabad