Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 24 lines (19 sloc) 881 Bytes
#! /usr/bin/python
import os
import random
import argparse
def choose_background(path):
files = []
for root, dirs, temp_files in os.walk(path, followlinks=True):
files.extend([os.sep.join((root, f)) for f in temp_files
if f[-3:].lower() in ('jpg', 'png', 'jpeg', 'gif')])
if len(files) > 0:
choice = random.randint(0,len(files)-1)
wall = os.path.join(os.path.abspath(path),files[choice])
os.system('gconftool-2 --set /desktop/gnome/background/picture_filename --type string "%s"' % wall)
return wall
if __name__ == '__main__':
parser = argparse.ArgumentParser(description="""Choose an arbitrary file to set on the background""")
parser.add_argument(dest='path', help='path you want to choose the image from')
args = parser.parse_args()
print 'selected %s' % choose_background(args.path)
Jump to Line
Something went wrong with that request. Please try again.