mirror of
https://github.com/anufrievroman/waypaper.git
synced 2024-11-22 07:22:19 +03:00
Implementing stop button for mpvpaper
This commit is contained in:
parent
3d41556570
commit
52fef50a0e
@ -213,6 +213,10 @@ class App(Gtk.Window):
|
||||
self.color_picker_button.connect("color-set", self.on_color_set)
|
||||
self.color_picker_button.set_tooltip_text(self.txt.tip_color)
|
||||
|
||||
# Create mpv stop button:
|
||||
self.mpv_stop_button = Gtk.Button(label=self.txt.msg_stop)
|
||||
self.mpv_stop_button.connect("clicked", self.on_mpv_stop_button_clicked)
|
||||
|
||||
# Create a box to contain the bottom row of buttons with margin:
|
||||
self.bottom_button_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=60)
|
||||
self.bottom_button_box.set_margin_bottom(15)
|
||||
@ -260,6 +264,7 @@ class App(Gtk.Window):
|
||||
|
||||
# Add different buttons depending on backend:
|
||||
self.monitor_option_display()
|
||||
self.mpv_options_display()
|
||||
self.fill_option_display()
|
||||
self.color_picker_display()
|
||||
self.swww_options_display()
|
||||
@ -326,7 +331,7 @@ class App(Gtk.Window):
|
||||
self.options_box.pack_start(self.monitor_option_combo, False, False, 0)
|
||||
|
||||
def swww_options_display(self) -> None:
|
||||
""" Show swww transition options if backend is swww """
|
||||
"""Show swww transition options if backend is swww"""
|
||||
self.options_box.remove(self.swww_transitions_options)
|
||||
self.options_box.remove(self.swww_angle_entry)
|
||||
self.options_box.remove(self.swww_steps_entry)
|
||||
@ -352,6 +357,14 @@ class App(Gtk.Window):
|
||||
self.options_box.pack_end(self.swww_duration_entry, False, False, 0)
|
||||
self.options_box.pack_end(self.swww_transitions_options, False, False, 0)
|
||||
|
||||
|
||||
def mpv_options_display(self) -> None:
|
||||
"""Show mpv options if backend is mpvpaper"""
|
||||
self.options_box.remove(self.mpv_stop_button)
|
||||
if self.cf.backend != "mpvpaper":
|
||||
return
|
||||
self.options_box.pack_end(self.mpv_stop_button, False, False, 0)
|
||||
|
||||
def fill_option_display(self):
|
||||
"""Display fill option if backend is not hyprpaper"""
|
||||
self.options_box.remove(self.fill_option_combo)
|
||||
@ -654,6 +667,9 @@ class App(Gtk.Window):
|
||||
"""On clicking refresh button, clear cache"""
|
||||
self.clear_cache()
|
||||
|
||||
def on_mpv_stop_button_clicked(self, widget) -> None:
|
||||
"""On clicking mpv stop button, kill the mpvpaper"""
|
||||
subprocess.Popen(["killall", "mpvpaper"])
|
||||
|
||||
def on_random_clicked(self, widget) -> None:
|
||||
"""On clicking random button, set random wallpaper"""
|
||||
|
@ -8,7 +8,8 @@ from waypaper.config import Config
|
||||
from waypaper.common import get_monitor_names
|
||||
from waypaper.translations import Chinese, English, French, German, Polish, Russian, Belarusian
|
||||
|
||||
def change_wallpaper(image_path: Path, cf: Config, monitor: str, txt: Chinese|English|French|German|Polish|Russian|Belarusian):
|
||||
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:
|
||||
@ -51,17 +52,17 @@ def change_wallpaper(image_path: Path, cf: Config, monitor: str, txt: Chinese|En
|
||||
print("Detected running mpvpaper on {monitor}, now trying to call mpvpaper socket")
|
||||
subprocess.Popen(f"echo 'loadfile \"{image_path}\"' | socat - /tmp/mpv-socket-{monitor}", shell=True)
|
||||
|
||||
# Otherwise, if no mpvpaper is running, create a new process in a new socket:
|
||||
# If mpvpaper is not running, create a new process in a new socket:
|
||||
except subprocess.CalledProcessError:
|
||||
print("Detected no running mpvpaper, starting new mpvpaper process")
|
||||
command = ["mpvpaper", "--fork"]
|
||||
command.extend(["-o", f"input-ipc-server=/tmp/mpv-socket-{monitor} no-audio loop {fill} --background-color='{cf.color}'"])
|
||||
|
||||
# Specify the monitor:
|
||||
if monitor != "All":
|
||||
command.extend([monitor])
|
||||
else:
|
||||
if monitor == "All":
|
||||
command.extend('*')
|
||||
else:
|
||||
command.extend([monitor])
|
||||
|
||||
command.extend([image_path])
|
||||
subprocess.Popen(command)
|
||||
@ -70,8 +71,8 @@ def change_wallpaper(image_path: Path, cf: Config, monitor: str, txt: Chinese|En
|
||||
# swww backend:
|
||||
elif cf.backend == "swww":
|
||||
|
||||
# Check with pgrep if other backends they are running, and kill them
|
||||
# Because swaybg and hyprpaper are known to conflict with swww
|
||||
# Check with pgrep if other backends they are running and kill them
|
||||
# because swaybg and hyprpaper are known to conflict with swww
|
||||
try:
|
||||
subprocess.check_output(["pgrep", "swaybg"], encoding='utf-8')
|
||||
subprocess.Popen(["killall", "swaybg"])
|
||||
@ -94,7 +95,7 @@ def change_wallpaper(image_path: Path, cf: Config, monitor: str, txt: Chinese|En
|
||||
}
|
||||
fill = fill_types[cf.fill_option.lower()]
|
||||
|
||||
# Check if swww-deamon is already running. If not, launch it:
|
||||
# Check if swww-daemon is already running. If not, launch it:
|
||||
try:
|
||||
subprocess.check_output(["pgrep", "swww-daemon"], encoding='utf-8')
|
||||
except subprocess.CalledProcessError:
|
||||
@ -148,8 +149,8 @@ def change_wallpaper(image_path: Path, cf: Config, monitor: str, txt: Chinese|En
|
||||
|
||||
# Check if hyprpaper is already running, otherwise start it, and preload the wallpaper:
|
||||
try:
|
||||
str(subprocess.check_output(["pgrep", "hyprpaper"], encoding='utf-8'))
|
||||
except Exception:
|
||||
subprocess.check_output(["pgrep", "hyprpaper"], encoding='utf-8')
|
||||
except subprocess.CalledProcessError:
|
||||
subprocess.Popen(["hyprpaper"])
|
||||
time.sleep(1)
|
||||
preload_command = ["hyprctl", "hyprpaper", "preload", image_path]
|
||||
@ -177,11 +178,8 @@ def change_wallpaper(image_path: Path, cf: Config, monitor: str, txt: Chinese|En
|
||||
except Exception:
|
||||
retry_counter += 1
|
||||
|
||||
elif cf.backend == "none":
|
||||
pass
|
||||
|
||||
else:
|
||||
print(f"{txt.err_notsup} {cf.backend}")
|
||||
pass
|
||||
|
||||
# Run a post command:
|
||||
if cf.post_command:
|
||||
|
@ -20,6 +20,7 @@ class English:
|
||||
self.msg_select = "Select"
|
||||
self.msg_refresh = "Refresh"
|
||||
self.msg_clear = "Clear"
|
||||
self.msg_stop = "Stop"
|
||||
self.msg_search = "Search"
|
||||
self.msg_random = "Random"
|
||||
self.msg_exit = "Exit"
|
||||
@ -44,7 +45,6 @@ class English:
|
||||
self.err_backend += "- hyprpaper (for Wayland)\n- feh (for Xorg)\n- wallutils (for Xorg & Wayland)\n\n"
|
||||
self.err_backend += self.msg_info
|
||||
self.err_wall = "Error changing wallpaper:"
|
||||
self.err_notsup = "The backend is not supported:"
|
||||
self.err_disp = "Error determining monitor names:"
|
||||
|
||||
self.tip_refresh = "Recache the folder of images"
|
||||
@ -78,6 +78,7 @@ class German:
|
||||
self.msg_refresh = "Aktualisieren"
|
||||
self.msg_random = "Zufällig"
|
||||
self.msg_clear = "Clear"
|
||||
self.msg_stop = "Stop"
|
||||
self.msg_search = "Search"
|
||||
self.msg_exit = "Beenden"
|
||||
self.msg_subfolders = "Unterordner"
|
||||
@ -101,7 +102,6 @@ class German:
|
||||
self.err_backend += "- hyprpaper (fur Wayland)\n- feh (für Xorg)\n- wallutils (für Xorg & Wayland)\n\n"
|
||||
self.err_backend += self.msg_info
|
||||
self.err_wall = "Fehler beim Ändern des Hintergrundbildes:"
|
||||
self.err_notsup = "Das folgende Backend wird nicht unterstützt:"
|
||||
self.err_disp = "Fehler beim Ermitteln der Monitor-Namen:"
|
||||
|
||||
self.tip_refresh = "Erneutes einlesen des Hintergrundbild-Ordners"
|
||||
@ -135,6 +135,7 @@ class French:
|
||||
self.msg_refresh = "Actualiser"
|
||||
self.msg_random = "Aléatoire"
|
||||
self.msg_clear = "Effacer"
|
||||
self.msg_stop = "Stop"
|
||||
self.msg_search = "Chercher"
|
||||
self.msg_exit = "Quitter"
|
||||
self.msg_subfolders = "Sous-dossiers"
|
||||
@ -158,7 +159,6 @@ class French:
|
||||
self.err_backend += "- hyprpaper (pour Wayland)\n- feh (pour Xorg)\n- wallutils (pour Xorg & Wayland)\n\n"
|
||||
self.err_backend += self.msg_info
|
||||
self.err_wall = "Erreur lors du changement de papier peint :"
|
||||
self.err_notsup = "Le backend n'est pas pris en charge :"
|
||||
self.err_disp = "Erreur lors de la détermination des noms des moniteurs :"
|
||||
|
||||
self.tip_refresh = "Recréer le dossier d'images"
|
||||
@ -192,6 +192,7 @@ class Polish:
|
||||
self.msg_refresh = "Odśwież"
|
||||
self.msg_random = "Losowo"
|
||||
self.msg_clear = "Clear"
|
||||
self.msg_stop = "Stop"
|
||||
self.msg_search = "Search"
|
||||
self.msg_exit = "Wyjście"
|
||||
self.msg_subfolders = "Podkatalogi"
|
||||
@ -215,7 +216,6 @@ class Polish:
|
||||
self.err_backend += "- hyprpaper (dla Wayland)\n- feh (dla Xorg)\n- wallutils (dla Xorg i Wayland)\n\n"
|
||||
self.err_backend += self.msg_info
|
||||
self.err_wall = "Błąd podczas zmiany tapety:"
|
||||
self.err_notsup = "Backend nie jest obsługiwany:"
|
||||
self.err_disp = "Błąd podczas określania nazw monitorów:"
|
||||
|
||||
self.tip_refresh = "Odśwież folder z obrazami"
|
||||
@ -249,6 +249,7 @@ class Russian:
|
||||
self.msg_refresh = "Обновить"
|
||||
self.msg_random = "Случайно"
|
||||
self.msg_clear = "Очистить"
|
||||
self.msg_stop = "Остановить"
|
||||
self.msg_search = "Поиск"
|
||||
self.msg_exit = "Выход"
|
||||
self.msg_subfolders = "Показать подпапки"
|
||||
@ -272,7 +273,6 @@ class Russian:
|
||||
self.err_backend += "- hyprpaper (для Wayland)\n- feh (для Xorg)\n- wallutils (для Xorg и Wayland)\n\n"
|
||||
self.err_backend += self.msg_info
|
||||
self.err_wall = "Ошибка при смене обоев:"
|
||||
self.err_notsup = "Бэкенд не поддерживается:"
|
||||
self.err_disp = "Ошибка определения названий мониторов:"
|
||||
|
||||
self.tip_refresh = "Обновить папку с изображениями"
|
||||
@ -306,6 +306,7 @@ class Belarusian:
|
||||
self.msg_refresh = "Абнавіць"
|
||||
self.msg_random = "Выпадкова"
|
||||
self.msg_clear = "Clear"
|
||||
self.msg_stop = "Stop"
|
||||
self.msg_search = "Search"
|
||||
self.msg_exit = "Вынахад"
|
||||
self.msg_subfolders = "Паказаць падтэчкі"
|
||||
@ -329,7 +330,6 @@ class Belarusian:
|
||||
self.err_backend += "- hyprpaper (для Wayland)\n- feh (для Xorg)\n- wallutils (для Xorg і Wayland)\n\n"
|
||||
self.err_backend += self.msg_info
|
||||
self.err_wall = "Памылка пры змене шпалер:"
|
||||
self.err_notsup = "Бэкенд не падтрымліваецца:"
|
||||
self.err_disp = "Памылка вызначэння назваў манітораў:"
|
||||
|
||||
self.tip_refresh = "Абнавіць тэчку з выявамі"
|
||||
@ -363,6 +363,7 @@ class Chinese:
|
||||
self.msg_refresh = "刷新"
|
||||
self.msg_random = "随机"
|
||||
self.msg_clear = "Clear"
|
||||
self.msg_stop = "Stop"
|
||||
self.msg_search = "Search"
|
||||
self.msg_exit = "退出"
|
||||
self.msg_subfolders = "子文件夹"
|
||||
@ -386,7 +387,6 @@ class Chinese:
|
||||
self.err_backend += "- hyprpaper (对于 Wayland)\n-feh (对于 Xorg)\n-wallutils (对于 Xorg 和 Wayland)\n\n"
|
||||
self.err_backend += self.msg_info
|
||||
self.err_wall = "更改壁纸时出错:"
|
||||
self.err_notsup = "不支持后端:"
|
||||
self.err_disp = "确定监视器名称时出错:"
|
||||
|
||||
self.tip_refresh = "重新缓存图像文件夹"
|
||||
@ -419,6 +419,7 @@ class Spanish:
|
||||
self.msg_refresh = "Actualizar"
|
||||
self.msg_random = "Aleatorio"
|
||||
self.msg_clear = "Clear"
|
||||
self.msg_stop = "Stop"
|
||||
self.msg_search = "Search"
|
||||
self.msg_exit = "Salir"
|
||||
self.msg_subfolders = "Ver subcarpetas"
|
||||
@ -442,7 +443,6 @@ class Spanish:
|
||||
self.err_backend += '- hyprpaper (para "Wayland")\n- feh (para "Xorg")\n- wallutils (para "Xorg" y "Wayland")\n\n'
|
||||
self.err_backend += self.msg_info
|
||||
self.err_wall = "Error cambiando imagen de fondo:"
|
||||
self.err_notsup = "El programa para cambiar la imagen de fondo no tiene soporte:"
|
||||
self.err_disp = "Error buscando nombres de monitores"
|
||||
|
||||
self.tip_refresh = "Volver a almacenar la carpeta de imágenes"
|
||||
|
Loading…
Reference in New Issue
Block a user