#!/usr/bin/python import glob, random, shlex, subprocess debug = 0 desktops = [1, 2, 3, 4] file_extensions = ['jpg', 'tif', 'png'] image_dir = "/media/mmc1/DCIM/" images = [] for current_file_extension in file_extensions: images = images + glob.glob(image_dir + '*.' + current_file_extension) images = images + glob.glob(image_dir + '*/*.' + current_file_extension) if debug: print images for current_desktop in desktops: new_image = images[random.randint(1, len(images)) - 1] cmd = "gconftool-2 --type string --set /apps/osso/hildon-desktop/views/%d/bg-image '%s'" % (current_desktop, new_image) if debug: print cmd args = shlex.split(cmd) if debug: print args subprocess.Popen(args)