mirror of
https://github.com/anufrievroman/waypaper.git
synced 2024-11-22 07:22:19 +03:00
parent
6ce73e4c9f
commit
84afef9ad1
@ -49,22 +49,27 @@ 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:
|
||||
# Set monitor and wallpaper from user arguments:
|
||||
if args.monitor:
|
||||
monitor = args.monitor
|
||||
|
||||
# Set wallpaper from user arguments
|
||||
# Set wallpaper from user arguments:
|
||||
if args.wallpaper:
|
||||
wallpaper = pathlib.Path(args.wallpaper).expanduser()
|
||||
|
||||
if args.random:
|
||||
# Set random wallpaper:
|
||||
elif 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)
|
||||
else:
|
||||
print("Could not get random wallpaper.")
|
||||
wallpaper = pathlib.Path("")
|
||||
|
||||
# If no wallpaper provided, show error:
|
||||
else:
|
||||
print("The --monitor argument equires also using --wallpaper or --random.")
|
||||
sys.exit(0)
|
||||
|
||||
change_wallpaper(wallpaper, cf, monitor, txt)
|
||||
time.sleep(0.1)
|
||||
@ -76,7 +81,7 @@ def run():
|
||||
cf.save()
|
||||
sys.exit(0)
|
||||
|
||||
# Set the wallpapers and quit:
|
||||
# Set previous wallpapers or random wallpaper:
|
||||
if args.restore or args.random:
|
||||
for index, (wallpaper, monitor) in enumerate(zip(cf.wallpapers, cf.monitors)):
|
||||
|
||||
|
@ -7,13 +7,14 @@ import time
|
||||
import gi
|
||||
import shutil
|
||||
import imageio
|
||||
import screeninfo
|
||||
from pathlib import Path
|
||||
from PIL import Image
|
||||
|
||||
from waypaper.aboutdata import AboutData
|
||||
from waypaper.changer import change_wallpaper
|
||||
from waypaper.config import Config
|
||||
from waypaper.common import get_image_paths, get_random_file, get_monitor_names
|
||||
from waypaper.common import get_image_paths, get_random_file
|
||||
from waypaper.options import FILL_OPTIONS, SORT_OPTIONS, SORT_DISPLAYS, VIDEO_EXTENSIONS , SWWW_TRANSITION_TYPES
|
||||
from waypaper.translations import Chinese, English, French, German, Polish, Russian, Belarusian, Spanish
|
||||
|
||||
@ -319,7 +320,7 @@ class App(Gtk.Window):
|
||||
monitor_names = ["All"]
|
||||
if self.cf.backend in ["feh", "wallutils", "none"]:
|
||||
return
|
||||
monitor_names.extend(get_monitor_names())
|
||||
monitor_names.extend([m.name for m in screeninfo.get_monitors()])
|
||||
|
||||
# Create a monitor option dropdown menu:
|
||||
self.monitor_option_combo = Gtk.ComboBoxText()
|
||||
|
@ -2,10 +2,10 @@
|
||||
|
||||
import subprocess
|
||||
import time
|
||||
import screeninfo
|
||||
from pathlib import Path
|
||||
|
||||
from waypaper.config import Config
|
||||
from waypaper.common import get_monitor_names
|
||||
from waypaper.translations import Chinese, English, French, German, Polish, Russian, Belarusian, Spanish
|
||||
|
||||
def change_wallpaper(image_path: Path, cf: Config, monitor: str,
|
||||
@ -157,7 +157,7 @@ def change_wallpaper(image_path: Path, cf: Config, monitor: str,
|
||||
|
||||
# Decide which monitors are affected:
|
||||
if monitor == "All":
|
||||
monitors = get_monitor_names()
|
||||
monitors = [m.name for m in screeninfo.get_monitors()]
|
||||
else:
|
||||
monitors: list = [monitor]
|
||||
|
||||
|
@ -6,9 +6,8 @@ import shutil
|
||||
|
||||
from pathlib import Path
|
||||
from typing import List
|
||||
from screeninfo import get_monitors
|
||||
|
||||
from waypaper.options import IMAGE_EXTENSIONS, BACKEND_OPTIONS, MONITOR_OPTIONS
|
||||
from waypaper.options import IMAGE_EXTENSIONS, BACKEND_OPTIONS
|
||||
|
||||
|
||||
def has_image_extension(file_path: str, backend: str) -> bool:
|
||||
@ -36,7 +35,7 @@ def get_image_paths(backend: str,
|
||||
if not include_subfolders and str(root) != str(root_folder):
|
||||
continue
|
||||
|
||||
# Remove deep w from consideration:
|
||||
# Remove deep folders from consideration:
|
||||
if depth is not None and root != root_folder:
|
||||
current_depth = root.count(os.path.sep) - str(root_folder).count(
|
||||
os.path.sep)
|
||||
@ -112,11 +111,3 @@ def check_installed_backends() -> List[str]:
|
||||
if is_installed:
|
||||
installed_backends.append(backend)
|
||||
return installed_backends
|
||||
|
||||
|
||||
def get_monitor_names() -> List[str]:
|
||||
"""Obtain the list of plugged monitors"""
|
||||
connected_monitors: List[str] = []
|
||||
for m in get_monitors():
|
||||
connected_monitors.append(m.name)
|
||||
return connected_monitors
|
||||
|
@ -1,8 +1,6 @@
|
||||
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"]
|
||||
SORT_OPTIONS: List[str] = ["name", "namerev", "date", "daterev"]
|
||||
@ -11,7 +9,7 @@ SORT_DISPLAYS: Dict[str, str] = {
|
||||
"namerev": "Name ↑",
|
||||
"date": "Date ↓",
|
||||
"daterev": "Date ↑"}
|
||||
MONITOR_OPTIONS: List[str] = connected_monitors
|
||||
MONITOR_OPTIONS: List[str] = [m.name for m in get_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',
|
||||
|
Loading…
Reference in New Issue
Block a user