XKCD Wallpaper

I confess, I like XKCD. Even though some of them are unfunny and others beyond my understanding, sometimes, just sometimes, they strike a chord.

Once I moved to pekwm I found myself with a black plain desktop, what could be better, I thought, than the current XKCD comic in the centre, with the tooltip comment located underneath in an appropriate font.

XKCD Wallpaper Screenshot After some trial and error, I ended up writing this script. It is far from perfect, and will probably end up being broken at some point, although it survived its first trial unscathed. I’m a little embarrassed by my tortuous curl/perl one-liner, ideally I would re-write this whole thing in perl, but it has worked reliably for a couple of months, so I dare say that I will never get around to it.

Currently it works for pekwm, and I dare say it will work for other lightweight window managers, like openbox, that can use feh to set the desktop wallpaper. If not, then it shouldn’t be too difficult to modify the script for your window manager or desktop environment. You can also run the script without the -w switch in order to just create the XKCD image in the directory for your own purposes.

You will obviously need perl, curl, wget, and fold, if they aren’t already installed on your system. Create a directory, say ~/.xkcd and save this script in there, along with the XKCD font, mark the script as executable. If you read the script, it is fairly self-explanatory I think.

You basically run it like this:

/path/to/.xkcd/xkcd -w -d '/path/to/.xkcd'

For pekwm, just add a line at the end of the ~/.pekwm/start file:

(sleep 30 && /path/to/.xkcd/xkcd -w -d '/path/to/.xkcd') &

I hope it works for you, feel free to comment any suggestions or criticisms. If you do start using it, it would be fantastic if you could add a comment to let me know.

comments powered by Disqus