mirror of
https://github.com/anufrievroman/waypaper.git
synced 2024-09-11 16:26:14 +03:00
parent
35fa33d44a
commit
1f0c345b09
2
setup.py
2
setup.py
@ -18,7 +18,7 @@ setuptools.setup(
|
||||
]
|
||||
},
|
||||
install_requires=["PyGObject", "importlib_metadata", "platformdirs", "Pillow"],
|
||||
version='2.0.4',
|
||||
version='2.1',
|
||||
python_requires='>3.9',
|
||||
classifiers=[
|
||||
"Development Status :: 4 - Beta",
|
||||
|
@ -9,16 +9,10 @@ from waypaper.options import BACKEND_OPTIONS
|
||||
def change_wallpaper(image_path, cf, monitor, txt):
|
||||
"""Run system commands to change the wallpaper depending on the backend"""
|
||||
|
||||
fill_option = cf.fill_option
|
||||
color = cf.color
|
||||
backend = cf.backend
|
||||
swww_transition = cf.swww_transition
|
||||
installed_backends = cf.installed_backends
|
||||
|
||||
try:
|
||||
# swaybg backend:
|
||||
if backend == "swaybg":
|
||||
fill = fill_option.lower()
|
||||
if cf.backend == "swaybg":
|
||||
fill = cf.fill_option.lower()
|
||||
try:
|
||||
subprocess.Popen(["killall", "swaybg"])
|
||||
time.sleep(0.005)
|
||||
@ -30,10 +24,10 @@ def change_wallpaper(image_path, cf, monitor, txt):
|
||||
command.extend(["-i", image_path])
|
||||
command.extend(["-m", fill, "-c", color])
|
||||
subprocess.Popen(command)
|
||||
print(f"{txt.msg_setwith} {backend}")
|
||||
print(f"{txt.msg_setwith} {cf.backend}")
|
||||
|
||||
# swww backend:
|
||||
elif backend == "swww":
|
||||
elif cf.backend == "swww":
|
||||
fill_types = {
|
||||
"fill": "crop",
|
||||
"fit": "fit",
|
||||
@ -41,8 +35,8 @@ def change_wallpaper(image_path, cf, monitor, txt):
|
||||
"stretch": "crop",
|
||||
"tile": "no",
|
||||
}
|
||||
fill = fill_types[fill_option.lower()]
|
||||
if "swaybg" in installed_backends:
|
||||
fill = fill_types[cf.fill_option.lower()]
|
||||
if "swaybg" in cf.installed_backends:
|
||||
try:
|
||||
subprocess.Popen(["killall", "swaybg"])
|
||||
time.sleep(0.005)
|
||||
@ -51,16 +45,16 @@ def change_wallpaper(image_path, cf, monitor, txt):
|
||||
subprocess.Popen(["swww", "init"])
|
||||
command = ["swww", "img", image_path]
|
||||
command.extend(["--resize", fill])
|
||||
command.extend(["--fill-color", color])
|
||||
command.extend(["--transition-type", swww_transition])
|
||||
command.extend(["--fill-color", cf.color])
|
||||
command.extend(["--transition-type", cf.swww_transition])
|
||||
# command.extend(["--transition-step", str(30)])
|
||||
if monitor != "All":
|
||||
command.extend(["--outputs", monitor])
|
||||
subprocess.Popen(command)
|
||||
print(f"{txt.msg_setwith} {backend}")
|
||||
print(f"{txt.msg_setwith} {cf.backend}")
|
||||
|
||||
# feh backend:
|
||||
elif backend == "feh":
|
||||
elif cf.backend == "feh":
|
||||
fill_types = {
|
||||
"fill": "--bg-fill",
|
||||
"fit": "--bg-max",
|
||||
@ -68,14 +62,14 @@ def change_wallpaper(image_path, cf, monitor, txt):
|
||||
"stretch": "--bg-scale",
|
||||
"tile": "--bg-tile",
|
||||
}
|
||||
fill = fill_types[fill_option.lower()]
|
||||
command = ["feh", fill, "--image-bg", color]
|
||||
fill = fill_types[cf.fill_option.lower()]
|
||||
command = ["feh", fill, "--image-bg", cf.color]
|
||||
command.extend([image_path])
|
||||
subprocess.Popen(command)
|
||||
print(f"{txt.msg_setwith} {backend}")
|
||||
print(f"{txt.msg_setwith} {cf.backend}")
|
||||
|
||||
# wallutils backend:
|
||||
elif backend == "wallutils":
|
||||
elif cf.backend == "wallutils":
|
||||
fill_types = {
|
||||
"fill": "scale",
|
||||
"fit": "scale",
|
||||
@ -83,13 +77,18 @@ def change_wallpaper(image_path, cf, monitor, txt):
|
||||
"stretch": "stretch",
|
||||
"tile": "tile",
|
||||
}
|
||||
fill = fill_types[fill_option.lower()]
|
||||
fill = fill_types[cf.fill_option.lower()]
|
||||
|
||||
subprocess.Popen(["setwallpaper", "--mode", fill, image_path])
|
||||
print(f"{txt.msg_setwith} {backend}")
|
||||
print(f"{txt.msg_setwith} {cf.backend}")
|
||||
|
||||
else:
|
||||
print(f"{txt.err_notsup} {backend}")
|
||||
print(f"{txt.err_notsup} {cf.backend}")
|
||||
|
||||
if cf.post_command:
|
||||
command = cf.post_command.split(" ")
|
||||
subprocess.Popen(command)
|
||||
print(f"{cf.post_command} executed")
|
||||
|
||||
except Exception as e:
|
||||
print(f"{txt.err_wall} {e}")
|
||||
|
@ -26,6 +26,7 @@ class Config:
|
||||
self.lang = "en"
|
||||
self.monitors = [self.selected_monitor]
|
||||
self.wallpaper = []
|
||||
self.post_command = ""
|
||||
self.include_subfolders = False
|
||||
self.about = AboutData()
|
||||
self.cache_dir = user_cache_path(self.about.applicationName())
|
||||
@ -52,6 +53,7 @@ class Config:
|
||||
self.sort_option = SORT_OPTIONS[0]
|
||||
self.backend = config.get("Settings", "backend", fallback=self.backend)
|
||||
self.color = config.get("Settings", "color", fallback=self.color)
|
||||
self.post_command = config.get("Settings", "post_command", fallback=self.post_command)
|
||||
self.swww_transition = config.get("Settings", "swww_transition", fallback=self.swww_transition)
|
||||
if self.swww_transition not in SWWW_TRANSITIONS:
|
||||
self.swww_transition = "any"
|
||||
@ -96,6 +98,7 @@ class Config:
|
||||
config.set("Settings", "subfolders", str(self.include_subfolders))
|
||||
config.set("Settings", "wallpaper", ",".join(self.wallpaper))
|
||||
config.set("Settings", "monitors", ",".join(self.monitors))
|
||||
config.set("Settings", "post_command", self.post_command)
|
||||
with open(self.config_file, "w") as configfile:
|
||||
config.write(configfile)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user