diff --git a/docs/.README_ru.md.swp b/docs/.README_ru.md.swp deleted file mode 100644 index b06411c..0000000 Binary files a/docs/.README_ru.md.swp and /dev/null differ diff --git a/func.py b/func.py index 1d3a1be..bd12f8c 100644 --- a/func.py +++ b/func.py @@ -1,9 +1,7 @@ import os import random -from apscheduler.schedulers.background import BlockingScheduler - -PATH = '/home/arthur/img/Wallpapers/wallpyper/'# path to media +PATH = '/home/arthur/img/Wallpapers/wallpyper/'# path to media (wallpaper) files = os.listdir(PATH) def run(command,output=False): @@ -14,14 +12,19 @@ def run(command,output=False): os.system(command + devNull) def kill(): - with open('/tmp/wallpyper','r') as file: + ''' + back4.sh will output artifacts if run more 2 processes + It function read PID in /tmp/back4.sh.pid, and kill process. + ''' + with open('/tmp/back4.sh.pid','r') as file: for pid in file: run(f'kill {pid}') -def setWallPeper(): +def setWallPaper(): media = random.choices(files)[0] if media[-4:] != '.gif': run(f"feh --bg-scale {PATH}{media}") else: - run(f"back4.sh auto {PATH}{media} & echo $! > /tmp/wallpyper",True) + run(f"back4.sh auto {PATH}{media} & echo $! > /tmp/back4.sh.pid",True) + # > tmp/back4.sh.pid write PID for kill() diff --git a/main.py b/main.py index 15f9e7e..0446342 100755 --- a/main.py +++ b/main.py @@ -1,14 +1,15 @@ #!/usr/bin/python3 +from apscheduler.schedulers.background import BlockingScheduler from func import * def start(): try: kill() except FileNotFoundError: - setWallPeper() + setWallPaper() - setWallPeper() + setWallPaper() if __name__ == '__main__': start()