Implementing transition option for swww

This addresses issue #20
This commit is contained in:
Roman 2023-12-31 18:05:02 +01:00
parent 3cd2f7ff9c
commit 0733122f82
5 changed files with 15 additions and 7 deletions

View File

@ -54,7 +54,7 @@ def run():
if wallpaper is None:
continue
change_wallpaper(wallpaper, cf.fill_option, cf.color, cf.backend, monitor, txt)
change_wallpaper(wallpaper, cf.fill_option, cf.color, cf.backend, monitor, cf.swww_transition, txt)
time.sleep(0.1)
exit(0)

View File

@ -412,7 +412,7 @@ class App(Gtk.Window):
print(self.txt.msg_path, self.cf.selected_wallpaper)
self.cf.fill_option = self.fill_option_combo.get_active_text() or self.cf.fill_option
change_wallpaper(self.cf.selected_wallpaper, self.cf.fill_option, self.cf.color,
self.cf.backend, self.cf.selected_monitor, self.txt)
self.cf.backend, self.cf.selected_monitor, self.cf.swww_transition, self.txt)
self.cf.save()
@ -439,7 +439,7 @@ class App(Gtk.Window):
print(self.txt.msg_path, self.cf.selected_wallpaper)
self.cf.fill_option = self.fill_option_combo.get_active_text() or self.cf.fill_option
change_wallpaper(self.cf.selected_wallpaper, self.cf.fill_option, self.cf.color,
self.cf.backend, self.cf.selected_monitor, self.txt)
self.cf.backend, self.cf.selected_monitor, self.cf.swww_transition, self.txt)
self.cf.save()
@ -507,7 +507,7 @@ class App(Gtk.Window):
print(self.txt.msg_path, self.cf.selected_wallpaper)
self.cf.fill_option = self.fill_option_combo.get_active_text() or self.cf.fill_option
change_wallpaper(self.cf.selected_wallpaper, self.cf.fill_option, self.cf.color,
self.cf.backend, self.cf.selected_monitor, self.txt)
self.cf.backend, self.cf.selected_monitor, self.cf.swww_transition, self.txt)
self.cf.save()
# Prevent other default key handling:

View File

@ -4,7 +4,7 @@ import subprocess
import time
def change_wallpaper(image_path, fill_option, color, backend, monitor, txt):
def change_wallpaper(image_path, fill_option, color, backend, monitor, transition, txt):
"""Run a system command to change the wallpaper depending on the backend"""
try:
@ -43,7 +43,8 @@ def change_wallpaper(image_path, fill_option, color, backend, monitor, txt):
command = ["swww", "img", image_path]
command.extend(["--resize", fill])
command.extend(["--fill-color", color])
command.extend(["--transition-step", str(10)])
command.extend(["--transition-type", transition])
# command.extend(["--transition-step", str(30)])
if monitor != "All":
command.extend(["--outputs", monitor])
subprocess.Popen(command)

View File

@ -7,7 +7,7 @@ from sys import exit
from platformdirs import user_config_path, user_pictures_path, user_cache_path
from waypaper.aboutdata import AboutData
from waypaper.options import FILL_OPTIONS, SORT_OPTIONS
from waypaper.options import FILL_OPTIONS, SORT_OPTIONS, SWWW_TRANSITIONS
class Config:
"""User configuration loaded from the config.ini file"""
@ -19,6 +19,7 @@ class Config:
self.sort_option = "name"
self.backend = "swaybg"
self.color = "#ffffff"
self.swww_transition = "any"
self.lang = "en"
self.monitors = [self.selected_monitor]
self.wallpaper = []
@ -48,6 +49,9 @@ 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.swww_transition = config.get("Settings", "swww_transition", fallback=self.swww_transition)
if self.swww_transition not in SWWW_TRANSITIONS:
self.swww_transition = "any"
self.lang = config.get("Settings", "language", fallback=self.lang)
self.include_subfolders = config.getboolean("Settings", "subfolders", fallback=self.include_subfolders)
@ -84,6 +88,7 @@ class Config:
config.set("Settings", "sort", self.sort_option)
config.set("Settings", "backend", self.backend)
config.set("Settings", "color", self.color)
config.set("Settings", "swww_transition", self.swww_transition)
config.set("Settings", "language", self.lang)
config.set("Settings", "subfolders", str(self.include_subfolders))
config.set("Settings", "wallpaper", ",".join(self.wallpaper))

View File

@ -14,3 +14,5 @@ IMAGE_EXTENSIONS = {
BACKEND_OPTIONS[3]: ['.gif', '.jpg', '.jpeg', '.png'],
}
SWWW_TRANSITIONS = ["none", "simple", "fade", "wipe", "left", "right", "top", "bottom",
"wave", "grow", "center", "any", "outer", "random"]