mala::home Davide “+mala” Eynard’s website

21Nov/061

Perl Hacks: Random Wallpaper

Time ago I was searching for a random wallpaper changer for Gnome, but I couldn't find one which was ok for me. These were the features I wanted:

  • it had to be as simple as a random wallpaper changer should be (you know, something like you click and it changes your wallpaper. Oh yes, randomly!)
  • it had to deal not just with the background image (stretching or shrinking it) but also with all the other background properties I'm used to set with Gnome
  • it didn't have to scan a whole directory and get all the pix inside it, but just to select the few images I liked most

Well, I decided to solve the problem myself with a quick and dirty Perl script: randomwp.pl. It just scans your backgrounds.xml file where your various backgrounds settings are saved, chooses one background randomly and then applies it. Quick? Yes. Dirty? Yes. But most of all working! :-)

How to install:

  • just make sure you have perl installed in your system with the XML::Simple package. For instance, run
    perl -MXML::Simple -e 'print "Everything ok.n"'

    on your command line and if the answer is "Everything ok" then... well, I suppose everything is ok! Otherwise, you should install XML::Simple package using CPAN. What? You don't know how to do it? Go and learn it! A hint?

    perl -MCPAN -e 'install XML::Simple'
  • download the script and modify it so it matches your home backgrounds.xml file location (a hint: start changing the $HOME path)
  • make sure you have at least two backgrounds configured within Gnome
  • run the script from the command line:
    perl randomwp.pl

If everything works fine, you can customize it in many ways:

  • make it run automatically at system startup or every few minutes
  • put a new icon on the panel and make it executable with one click
  • create many backgrounds.xml and pass them as parameters, so you have different wallpaper pools to choose from
  • unleash your imagination :)
Filed under: hacks, perl Leave a comment
Comments (1) Trackbacks (0)
  1. I was just thinking about the web sence labeling monsters out there.
    It made me think aboutsome old crack sites that somehow managed to get around firewalls and filters to furnish you with a popup or a link that downloaded the beef you were looking for.
    wouldn’t it be nice to forget about having a defined web address to follow and have an initial address only (a nice non fingerprintable one) that would furnish a random page and continue on from there as if it were the original site.
    Kinda like a mirrorbot… only that the mirror dosen’t really exist…its just an url digester … take the GAME (how dare they) tagged 356* site ;-)
    then the hash mase would really be a mess no?
    L8r,
    Moonman


Leave a comment

No trackbacks yet.