diff --git a/waypaper/changer.py b/waypaper/changer.py index a5d6c0d..5f46dc2 100644 --- a/waypaper/changer.py +++ b/waypaper/changer.py @@ -9,7 +9,6 @@ from pathlib import Path import re def change_wallpaper(image_path: Path, cf: Config, monitor: str, txt: Chinese|English|French|German|Polish|Russian|Belarusian): - """Run system commands to change the wallpaper depending on the backend""" try: @@ -33,6 +32,28 @@ def change_wallpaper(image_path: Path, cf: Config, monitor: str, txt: Chinese|En subprocess.Popen(command) print(f"{txt.msg_setwith} {cf.backend}") + # mpvpaper backend: + elif cf.backend == "mpvpaper": + + # Kill previous mpvpaper instances: + try: + subprocess.check_output(["pgrep", "mpvpaper"], encoding='utf-8') + subprocess.Popen(["killall", ".mpvpaper-wrapp"]) + time.sleep(0.5) + except subprocess.CalledProcessError: + pass + + command = ["mpvpaper"] + command.extend(["-o", f"no-audio loop"]) + # if monitor != "All": + # command.extend([monitor]) + # else: + # command.extend('*') + command.extend('*') + command.extend([image_path]) + subprocess.Popen(command) + print(f"{txt.msg_setwith} {cf.backend}") + # swww backend: elif cf.backend == "swww": @@ -119,7 +140,7 @@ def change_wallpaper(image_path: Path, cf: Config, monitor: str, txt: Chinese|En subprocess.Popen(["hyprpaper"]) time.sleep(1) preload_command = ["hyprctl", "hyprpaper", "preload", image_path] - + # Decide which monitors are affected: if monitor == "All": monitors = get_monitor_names_hyprctl()