#!/usr/bin/env python # Change the wallpaper to a random image in a dir # ollie 6/6/07. #point this to the path of the images BACKGROUND_DIRS = ['/home/ollie/Wallpapers'] import os, glob, random, itertools, gconf files = list(itertools.chain(*[[os.path.join(dirpath, name) for name in filenames] for dirpath, dirnames, filenames in itertools.chain(*[os.walk(os.path.expanduser(d)) for d in BACKGROUND_DIRS])])) gconf.client_get_default().set_string( '/desktop/gnome/background/picture_filename', random.choice(files))