конфиги начало

This commit is contained in:
Arthur 2022-07-02 20:34:01 +05:00
parent f0791a5ff3
commit efc5fc1501
3 changed files with 19 additions and 10 deletions

1
config Normal file
View File

@ -0,0 +1 @@
path_to_wallpapers = "/home/arthur/img/Wallpapers/wallpyper"

24
func.py
View File

@ -1,14 +1,7 @@
import json
import os import os
import random import random
import sys 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): def run(command,output=False):
devNull = ">/dev/null" devNull = ">/dev/null"
@ -26,7 +19,20 @@ def kill():
for pid in file: for pid in file:
run(f'kill {pid}') 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(): def setWallPaper():
config = configParsing()
PATH = config['path_to_wallpapers']
files = os.listdir(PATH)
media = random.choices(files)[0] media = random.choices(files)[0]
if media[-4:] != '.gif': if media[-4:] != '.gif':
@ -34,3 +40,5 @@ def setWallPaper():
else: else:
run(f"back4.sh auto {PATH}{media} & echo $! > /tmp/back4.sh.pid",True) run(f"back4.sh auto {PATH}{media} & echo $! > /tmp/back4.sh.pid",True)
# > tmp/back4.sh.pid write PID for kill() # > tmp/back4.sh.pid write PID for kill()
setWallPaper()

View File

@ -15,5 +15,5 @@ if __name__ == '__main__':
start() start()
sched = BlockingScheduler() sched = BlockingScheduler()
sched.add_job(start,'interval',minutes=1) sched.add_job(start,'interval',minutes=configParsing()['value'])
sched.start() sched.start()