feat: add condition for mpvpaper backend

This commit is contained in:
Kritagya Bhattarai (CalfMoon) 2024-10-12 21:53:59 +05:45
parent a3cc58739f
commit 960c86423b

View File

@ -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()