Rotating GNOME Wallpaper in Fedora 10

We don't usually talk programming here on Pun Salad, but …

I wrote a small Perl script a number of years ago that would rotate the "wallpaper" background on my Linux boxes, changing it to the least-recently-used JPEG file in a directory collection I've maintained. I stuck the script in my crontab file to execute every hour, and—voila!—I was mildly entertained by the automatically-changing background of scenic vistas, cute animals, etc.

This stopped working when I upgraded to Fedora 10. And, eventually, I noticed: my background was stuck on the same picture throughout my login session.

Telling symptom: the script worked fine when I ran it from the command line, but it was not working out of crontab.

Explanation: In GNOME (Fedora's default desktop software), the actual background-changing work is performed by a program called gconftool-2; the latest version requires an environment variable (specifically, DBUS_SESSION_BUS_ADDRESS) to be set in order to affect the current session's configuration. This environment variable is automatically provided to programs run from the command line, but aren't normally available to programs run out of crontab.

So I had to add some lines to my script to dig out the value of this variable and make it avaiable to gconftool-2; fortunately, this article from the Srijith Unplugged blog showed a technique for making that happen in a Bash script that wasn't tough to translate to Perl.

More information and a pointer to my script is on my "Hacks" site here.

Last Modified 2012-10-08 8:25 PM EDT