Skip to content

Instantly share code, notes, and snippets.

@nzjrs nzjrs/changer.py
Created Oct 5, 2013

Embed
What would you like to do?
Timed background changer for gnome
import argparse
import random
import glob
import os.path
import time
from gi.repository import Gio
class Changer:
def __init__(self, directory, interval):
self._pics = glob.glob(os.path.join(directory,"*.jpg"))
self._interval = interval
def run(self):
gsetting = Gio.Settings('org.gnome.desktop.background')
while len(self._pics):
pic = random.choice(self._pics)
gsetting['picture-uri'] = 'file://' + os.path.abspath(pic)
time.sleep(self._interval)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--time", default=60, type=int,
help="interval to change in seconds")
parser.add_argument("--folder", default='/usr/share/backgrounds/gnome/',
help="folder containing images")
args = parser.parse_args()
Changer(args.folder, args.time).run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.