diff --git a/data/waypaper.desktop b/data/waypaper.desktop old mode 100644 new mode 100755 index 3b206af..0eb59fa --- a/data/waypaper.desktop +++ b/data/waypaper.desktop @@ -1,3 +1,4 @@ +#!/usr/bin/env xdg-open [Desktop Entry] Encoding=UTF-8 Type=Application diff --git a/waypaper/__main__.py b/waypaper/__main__.py index 52fe212..09d3df0 100644 --- a/waypaper/__main__.py +++ b/waypaper/__main__.py @@ -11,7 +11,7 @@ from waypaper.app import App from waypaper.changer import change_wallpaper from waypaper.common import get_random_file from waypaper.config import Config -from waypaper.options import BACKEND_OPTIONS, FILL_OPTIONS +from waypaper.options import BACKEND_OPTIONS, FILL_OPTIONS, MONITOR_OPTIONS from waypaper.translations import load_language @@ -36,6 +36,7 @@ parser.add_argument("--folder", help=txt.msg_arg_folder) parser.add_argument("--state-file", help=txt.msg_arg_statefile) parser.add_argument("--backend", help=txt.msg_arg_back, choices=BACKEND_OPTIONS) parser.add_argument("--list", help=txt.msg_arg_list, action='store_true') +parser.add_argument("--monitor", help=txt.msg_arg_monitor, choices=MONITOR_OPTIONS) args = parser.parse_args() @@ -48,6 +49,33 @@ def run(): cf.read_parameters_from_user_arguments(args) # user arguments override values from state file cf.check_validity() + # Set monitor from user arguments + if args.monitor and not args.wallpaper and not args.random: + print("--monitor Error! Requires an image to be set\nUse --wallpaper or --random") + sys.exit(0) + + if args.monitor and args.wallpaper or args.random: + monitor = args.monitor + + # Set wallpaper from user arguments + if args.wallpaper: + wallpaper = pathlib.Path(args.wallpaper).expanduser() + + if args.random: + wallpaper_str = get_random_file(cf.backend, str(cf.image_folder), cf.include_subfolders, cf.cache_dir, cf.show_hidden) + if wallpaper_str: + wallpaper = pathlib.Path(wallpaper_str) + + change_wallpaper(wallpaper, cf, monitor, txt) + time.sleep(0.1) + + # Save this wallpaper in config and quit: + cf.selected_wallpaper = wallpaper + cf.selected_monitor = monitor + cf.attribute_selected_wallpaper() + cf.save() + sys.exit(0) + # Set the wallpapers and quit: if args.restore or args.random: for index, (wallpaper, monitor) in enumerate(zip(cf.wallpapers, cf.monitors)): diff --git a/waypaper/common.py b/waypaper/common.py index 0dd30a0..435638b 100644 --- a/waypaper/common.py +++ b/waypaper/common.py @@ -8,7 +8,7 @@ from pathlib import Path from typing import List from screeninfo import get_monitors -from waypaper.options import IMAGE_EXTENSIONS, BACKEND_OPTIONS +from waypaper.options import IMAGE_EXTENSIONS, BACKEND_OPTIONS, MONITOR_OPTIONS def has_image_extension(file_path: str, backend: str) -> bool: @@ -120,4 +120,3 @@ def get_monitor_names() -> List[str]: for m in get_monitors(): connected_monitors.append(m.name) return connected_monitors - diff --git a/waypaper/options.py b/waypaper/options.py index 2b7ee4b..383f6bd 100644 --- a/waypaper/options.py +++ b/waypaper/options.py @@ -1,4 +1,7 @@ from typing import List, Dict +from screeninfo import get_monitors + +connected_monitors: List[str] = [m.name for m in get_monitors()] BACKEND_OPTIONS: List[str] = ["none", "swaybg", "swww", "feh", "wallutils", "hyprpaper", "mpvpaper"] FILL_OPTIONS: List[str] = ["fill", "stretch", "fit", "center", "tile"] @@ -8,6 +11,7 @@ SORT_DISPLAYS: Dict[str, str] = { "namerev": "Name ↑", "date": "Date ↓", "daterev": "Date ↑"} +MONITOR_OPTIONS: List[str] = connected_monitors VIDEO_EXTENSIONS: List[str] = ['.webm', '.mkv', '.flv', '.vob', '.ogv', '.ogg', '.rrc', '.gifv', '.mng', '.mov', '.avi', '.qt', '.wmv', '.yuv', '.rm', '.asf', '.amv', '.mp4', '.m4p', '.m4v', diff --git a/waypaper/translations.py b/waypaper/translations.py index 7828fc1..9d968da 100644 --- a/waypaper/translations.py +++ b/waypaper/translations.py @@ -15,6 +15,7 @@ class English: self.msg_arg_wall = "set the specified wallpaper" self.msg_arg_folder = "specify which folder to scan for wallpapers" self.msg_arg_statefile = "specify a custom file to store the application state" + self.msg_arg_monitor = "specify desired monitor using its name" self.msg_path = "Selected image path:" self.msg_select = "Select" @@ -77,6 +78,7 @@ class German: self.msg_arg_wall = "setzt das angegebene Hintergrundbild" self.msg_arg_folder = "legt fest, welcher Ordner nach Hintergrundbildern durchsucht werden soll" self.msg_arg_statefile = "specify a custom file to store the application state" + self.msg_arg_monitor = "geben Sie den gewünschten Monitor mit seinem Namen an" self.msg_path = "Pfad zum ausgewählten Bild:" self.msg_select = "Auswählen" @@ -138,7 +140,8 @@ class French: self.msg_arg_wall = "set the specified wallpaper" self.msg_arg_folder = "specify which folder to scan for wallpapers" self.msg_arg_statefile = "specify a custom file to store the application state" - + self.msg_arg_monitor = "spécifiez le moniteur souhaité en utilisant son nom" + self.msg_path = "Chemin de l'image sélectionnée :" self.msg_select = "Sélectionner" self.msg_refresh = "Actualiser" @@ -199,6 +202,7 @@ class Polish: self.msg_arg_wall = "set the specified wallpaper" self.msg_arg_folder = "specify which folder to scan for wallpapers" self.msg_arg_statefile = "specify a custom file to store the application state" + self.msg_arg_monitor = "укажите желаемый монитор, используя его имя" self.msg_path = "Wybrana ścieżka obrazu:" self.msg_select = "Wybierz" @@ -260,6 +264,7 @@ class Russian: self.msg_arg_wall = "указать путь к изображению" self.msg_arg_folder = "specify which folder to scan for wallpapers" self.msg_arg_statefile = "specify a custom file to store the application state" + self.msg_arg_monitor = "пакажыце патрэбны манітор, выкарыстоўваючы яго імя" self.msg_path = "Выбранный путь к изображению:" self.msg_select = "Выбрать" @@ -322,6 +327,7 @@ class Belarusian: self.msg_arg_wall = "пазначыць шлях да выявы" self.msg_arg_folder = "ўкажыце, які тэчку сканаваць для выявы" self.msg_arg_statefile = "ўкажыце карыстацкі файл для захавання стану прыкладання" + self.msg_arg_monitor = "określ żądany monitor, używając jego nazwy" self.msg_path = "Абраны шлях да выявы:" self.msg_select = "Выбраць" @@ -384,6 +390,7 @@ class Chinese: self.msg_arg_wall = "设置指定的壁纸" self.msg_arg_folder = "指定扫描壁纸的文件夹" self.msg_arg_statefile = "指定用于存储应用程序状态的自定义文件" + self.msg_arg_monitor = "通过其名称指定所需的显示器" self.msg_path = "选择的图像路径:" self.msg_select = "选择" @@ -445,6 +452,7 @@ class Spanish: self.msg_arg_wall = "establece el fondo especificado" self.msg_arg_folder = "specify which folder to scan for wallpapers" self.msg_arg_statefile = "specify a custom file to store the application state" + self.msg_arg_monitor = "especifique el monitor deseado usando su nombre" self.msg_path = "Ubicación de la imagen:" self.msg_select = "Selecciona"