code-archive/wallpaper_changer.py

15 lines
411 B
Python

#!/usr/bin/python
import os, os.path, random, gconf
startdir="/home/kairu/Pictures/wtf"
gkey="/desktop/gnome/background/picture_filename"
imgs=[]
for root, dirs, files in os.walk(startdir):
for file in files:
base, ext = os.path.splitext(file)
if ext.lower() in [".jpg", ".png", ".svg"]:
imgs.append(os.path.join(root, file))
img = random.choice(imgs)
gconf.client_get_default().set_string(gkey, img)