Created
October 5, 2013 19:19
-
-
Save nzjrs/6845044 to your computer and use it in GitHub Desktop.
Timed background changer for gnome
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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