Fix bug where wallpaper would not be set sometimes.

This commit is contained in:
nikolaizombie1 2024-05-31 06:24:09 -04:00
parent 4120bf97d4
commit 4379444183

View File

@ -4,6 +4,7 @@ import subprocess
import time import time
from waypaper.config import Config from waypaper.config import Config
from waypaper.translations import Chinese, English, French, German, Polish, Russian from waypaper.translations import Chinese, English, French, German, Polish, Russian
import sys
def change_wallpaper(image_path: str, cf: Config, monitor: str, txt: Chinese|English|French|German|Polish|Russian): def change_wallpaper(image_path: str, cf: Config, monitor: str, txt: Chinese|English|French|German|Polish|Russian):
@ -117,9 +118,14 @@ def change_wallpaper(image_path: str, cf: Config, monitor: str, txt: Chinese|Eng
monitor = "" monitor = ""
wallpaper_command = ["hyprctl", "hyprpaper", "wallpaper", f"{monitor},{image_path}"] wallpaper_command = ["hyprctl", "hyprpaper", "wallpaper", f"{monitor},{image_path}"]
unload_command = ["hyprctl", "hyprpaper", "unload", "all"] unload_command = ["hyprctl", "hyprpaper", "unload", "all"]
subprocess.Popen(unload_command) result: str = ""
subprocess.Popen(preload_command) while result != "ok":
subprocess.Popen(wallpaper_command) try:
result = subprocess.check_output(unload_command, encoding="utf-8").strip()
result = subprocess.check_output(preload_command, encoding="utf-8").strip()
result = subprocess.check_output(wallpaper_command, encoding="utf-8").strip()
except Exception:
continue
elif cf.backend == "none": elif cf.backend == "none":
pass pass