exif: Mon Dec 31 22:25:00 2007

Mon Dec 31 22:25:00 2007

I've had "make a screensaver that uses my kimdaba archive directly" on my todo list for rather a long time. Thanks to hiveminder, it finally percolated to the top... and turned out to be easier than I thought. (Not done, but easier.)

First step: find out how xscreensaver modules are written in the first place. Found a simple, though somewhat out of date, tutorial on writing them in C. Turns out that all that really matters is "draw something on someone else's window". (The tutorial has it as the root window; the modern implementation uses $XSCREENSAVER_WINDOW passed in the environment in hex.)

As sort of a tribute to the tutorial (for getting me off the ground), I duplicated the first exercise from scratch in python. xss_simplesquares.py does the same thing as the first tutorial, with two modifications:

Most of the use of python-xlib is painfully straightforward. The one trick is generating a window object from 0x80059E. After turning it into a number with int(windowid, 16), all you have to do is display.create_resource_object('window', windowid) to create a wrapper object that works just like any window you'd create directly.

You can just add this code to your .xscreensaver file, using the gui, or just add it to the programs: entry with all of the others.

Next step: actually tie this in with the other kimdaba/kphotoalbum XML file parsing code around here, and add an image renderer; that should be enough to implement "any picture with the tag(s) given on the commandline gets displayed". The hard part will be finding the motivation; these days, my photos-in-progress working set is on a memory stick, and not actually plugged in to the laptop.

(Also, don't let the lack of recent changes to python-xlib deter you; the protocol hasn't changed in many years, after all - even the code from my late-90's TPJ article on "Xlib in Pure Perl" still works. I am of course much more interested in the python version these days :-)