diff --git a/__pycache__/func.cpython-38.pyc b/__pycache__/func.cpython-38.pyc new file mode 100644 index 0000000..1f6280c Binary files /dev/null and b/__pycache__/func.cpython-38.pyc differ diff --git a/func.py b/func.py new file mode 100644 index 0000000..1d45515 --- /dev/null +++ b/func.py @@ -0,0 +1,26 @@ +import os +import random + +PATH = '/home/arthur/img/Wallpapers/media/'# path to media + +files = os.listdir(PATH) + +media = random.choices(files)[0] + +def run(command,output=False): + devNull = ">/dev/null" + if output == True: + os.system(command) + else: + os.system(command + devNull) + +def kill(): + with open('/tmp/wallpyper','r') as file: + for pid in file: + run(f'kill {pid}') + +def setWallPeper(): + if media[-4:] != '.gif': + run(f"feh --bg-scale {PATH}{media}") + else: + run(f"back4.sh auto {PATH}{media} & echo $! > /tmp/wallpyper",True) diff --git a/main.py b/main.py new file mode 100755 index 0000000..870c3cc --- /dev/null +++ b/main.py @@ -0,0 +1,7 @@ +#!/usr/bin/python3 + +from func import * + +if __name__ == '__main__': + kill() + setWallPeper() diff --git a/wallpyper.py b/wallpyper.py deleted file mode 100644 index a5dd802..0000000 --- a/wallpyper.py +++ /dev/null @@ -1,13 +0,0 @@ -import os -import random - -PATH = '/home/arthur/img/Wallpapers/media/'# path to media - -files = os.listdir(PATH) - -media = random.choices(files)[0] - -if media[-4:] != '.gif': - os.system(f"feh --bg-scale {PATH}{media}") -else: - os.system(f"back4.sh auto {PATH}{media}")