mirror of
https://github.com/anufrievroman/waypaper.git
synced 2024-08-17 04:00:23 +03:00
Compare commits
2 Commits
733b71c9a2
...
ba36d3ff21
Author | SHA1 | Date | |
---|---|---|---|
|
ba36d3ff21 | ||
|
0a59622b88 |
@ -4,7 +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
|
import re
|
||||||
|
|
||||||
|
|
||||||
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):
|
||||||
@ -115,18 +115,29 @@ def change_wallpaper(image_path: str, cf: Config, monitor: str, txt: Chinese|Eng
|
|||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
preload_command = ["hyprctl", "hyprpaper", "preload", image_path]
|
preload_command = ["hyprctl", "hyprpaper", "preload", image_path]
|
||||||
if monitor == "All":
|
if monitor == "All":
|
||||||
monitor = ""
|
monitors: list = []
|
||||||
wallpaper_command = ["hyprctl", "hyprpaper", "wallpaper", f"{monitor},{image_path}"]
|
# Check available motitors (using hyprpaper):
|
||||||
unload_command = ["hyprctl", "hyprpaper", "unload", "all"]
|
query_output = str(subprocess.check_output(["hyprctl", "monitors"], encoding='utf-8'))
|
||||||
result: str = ""
|
query_output = query_output.split('\n')
|
||||||
retry_counter: int = 0
|
# Use a regular expression to get the lines that contain the monitor names:
|
||||||
while result != "ok" and retry_counter < 10:
|
query_output = list(filter(lambda line: re.match(r"Monitor [a-zA-Z-0-9]+ \(ID \d+\):", line),query_output))
|
||||||
try:
|
for line in query_output:
|
||||||
result = subprocess.check_output(unload_command, encoding="utf-8").strip()
|
monitors.append(line.split(' ')[1])
|
||||||
result = subprocess.check_output(preload_command, encoding="utf-8").strip()
|
else:
|
||||||
result = subprocess.check_output(wallpaper_command, encoding="utf-8").strip()
|
monitors: list = [monitor]
|
||||||
except Exception:
|
for m in monitors:
|
||||||
retry_counter += 1
|
wallpaper_command = ["hyprctl", "hyprpaper", "wallpaper", f"{m},{image_path}"]
|
||||||
|
unload_command = ["hyprctl", "hyprpaper", "unload", "all"]
|
||||||
|
result: str = ""
|
||||||
|
retry_counter: int = 0
|
||||||
|
while result != "ok" and retry_counter < 10:
|
||||||
|
try:
|
||||||
|
subprocess.check_output(unload_command, encoding="utf-8").strip()
|
||||||
|
subprocess.check_output(preload_command, encoding="utf-8").strip()
|
||||||
|
result = subprocess.check_output(wallpaper_command, encoding="utf-8").strip()
|
||||||
|
time.sleep(0.1)
|
||||||
|
except Exception:
|
||||||
|
retry_counter += 1
|
||||||
|
|
||||||
elif cf.backend == "none":
|
elif cf.backend == "none":
|
||||||
pass
|
pass
|
||||||
|
Loading…
Reference in New Issue
Block a user