8 Jun
2010
I've got loads of wallpapers. I really like high resolution images and the idea of having them on my desktop is great. I have collected so many because I thought it would be great to have all these wallpapers on my desktop. Problem, though, I somehow never find the time to change between all these wallpapers. So I thought I would write a little python script that I could run on a cron job as well as on login to pick a random wallpaper from my wallpaper folder and change the displayed wallpaper on my desktop.
There may be the facility to do this already somewhere hidden in Gnome but I don't know about it and this seems like an incredibly simple solution.
Long overdue in my opinion, but here it is.
import os, random
WALLPAPER_DIR = '/path/to/wallpapers'
walls = os.listdir(WALLPAPER_DIR)
wallpaper = os.path.join(WALLPAPER_DIR, random.choice(walls))
if os.path.exists(wallpaper):
os.system('gconftool-2 -s -t string /desktop/gnome/background/picture_filename "%s"' % wallpaper)
Just save it somewhere it can execute from and run it as a cron job and/or at login.