diff --git a/config b/config new file mode 100644 index 0000000..2eda8e2 --- /dev/null +++ b/config @@ -0,0 +1 @@ +path_to_wallpapers = "/home/arthur/img/Wallpapers/wallpyper" diff --git a/func.py b/func.py index 908eb29..3d137be 100644 --- a/func.py +++ b/func.py @@ -1,14 +1,7 @@ +import json import os import random import sys -home = os.path.expanduser('~') -sys.path.insert(0, home+"/.config") -#sys.path.insert(0, '.config/wallpyper') -from wallpyper import config - - -PATH = config.path_to_wallpapers -files = os.listdir(PATH) def run(command,output=False): devNull = ">/dev/null" @@ -26,7 +19,20 @@ def kill(): for pid in file: run(f'kill {pid}') +def configParsing(): + pathToConfig = os.path.expanduser('~')+'/.config/wallpyper/config' + + with open(pathToConfig) as file: + contentFile = file.read() + config = json.loads(contentFile) + return config + def setWallPaper(): + config = configParsing() + + PATH = config['path_to_wallpapers'] + files = os.listdir(PATH) + media = random.choices(files)[0] if media[-4:] != '.gif': @@ -34,3 +40,5 @@ def setWallPaper(): else: run(f"back4.sh auto {PATH}{media} & echo $! > /tmp/back4.sh.pid",True) # > tmp/back4.sh.pid write PID for kill() + +setWallPaper() diff --git a/main.py b/main.py index 0446342..7e74025 100755 --- a/main.py +++ b/main.py @@ -15,5 +15,5 @@ if __name__ == '__main__': start() sched = BlockingScheduler() - sched.add_job(start,'interval',minutes=1) - sched.start() + sched.add_job(start,'interval',minutes=configParsing()['value']) + sched.start()