Skip to content

Commit

Permalink
Implementing transition option for swww
Browse files Browse the repository at this point in the history
This addresses issue #20
  • Loading branch information
anufrievroman committed Dec 31, 2023
1 parent 3cd2f7f commit 0733122
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion waypaper/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 3 additions & 3 deletions waypaper/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ def on_image_clicked(self, widget, path):
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()


Expand All @@ -439,7 +439,7 @@ def set_random_wallpaper(self):
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()


Expand Down Expand Up @@ -507,7 +507,7 @@ def on_key_pressed(self, widget, event):
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:
Expand Down
5 changes: 3 additions & 2 deletions waypaper/changer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
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:
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 6 additions & 1 deletion waypaper/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
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"""
Expand All @@ -19,6 +19,7 @@ def __init__(self):
self.sort_option = "name"
self.backend = "swaybg"
self.color = "#ffffff"
self.swww_transition = "any"
self.lang = "en"
self.monitors = [self.selected_monitor]
self.wallpaper = []
Expand Down Expand Up @@ -48,6 +49,9 @@ def read(self):
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)

Expand Down Expand Up @@ -84,6 +88,7 @@ def save(self):
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))
Expand Down
2 changes: 2 additions & 0 deletions waypaper/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@
BACKEND_OPTIONS[3]: ['.gif', '.jpg', '.jpeg', '.png'],
}

SWWW_TRANSITIONS = ["none", "simple", "fade", "wipe", "left", "right", "top", "bottom",
"wave", "grow", "center", "any", "outer", "random"]

0 comments on commit 0733122

Please sign in to comment.