Skip to content

Commit 0733122

Browse files
committed
Implementing transition option for swww
This addresses issue #20
1 parent 3cd2f7f commit 0733122

File tree

5 files changed

+15
-7
lines changed

5 files changed

+15
-7
lines changed

waypaper/__main__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def run():
5454

5555
if wallpaper is None:
5656
continue
57-
change_wallpaper(wallpaper, cf.fill_option, cf.color, cf.backend, monitor, txt)
57+
change_wallpaper(wallpaper, cf.fill_option, cf.color, cf.backend, monitor, cf.swww_transition, txt)
5858
time.sleep(0.1)
5959
exit(0)
6060

waypaper/app.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ def on_image_clicked(self, widget, path):
412412
print(self.txt.msg_path, self.cf.selected_wallpaper)
413413
self.cf.fill_option = self.fill_option_combo.get_active_text() or self.cf.fill_option
414414
change_wallpaper(self.cf.selected_wallpaper, self.cf.fill_option, self.cf.color,
415-
self.cf.backend, self.cf.selected_monitor, self.txt)
415+
self.cf.backend, self.cf.selected_monitor, self.cf.swww_transition, self.txt)
416416
self.cf.save()
417417

418418

@@ -439,7 +439,7 @@ def set_random_wallpaper(self):
439439
print(self.txt.msg_path, self.cf.selected_wallpaper)
440440
self.cf.fill_option = self.fill_option_combo.get_active_text() or self.cf.fill_option
441441
change_wallpaper(self.cf.selected_wallpaper, self.cf.fill_option, self.cf.color,
442-
self.cf.backend, self.cf.selected_monitor, self.txt)
442+
self.cf.backend, self.cf.selected_monitor, self.cf.swww_transition, self.txt)
443443
self.cf.save()
444444

445445

@@ -507,7 +507,7 @@ def on_key_pressed(self, widget, event):
507507
print(self.txt.msg_path, self.cf.selected_wallpaper)
508508
self.cf.fill_option = self.fill_option_combo.get_active_text() or self.cf.fill_option
509509
change_wallpaper(self.cf.selected_wallpaper, self.cf.fill_option, self.cf.color,
510-
self.cf.backend, self.cf.selected_monitor, self.txt)
510+
self.cf.backend, self.cf.selected_monitor, self.cf.swww_transition, self.txt)
511511
self.cf.save()
512512

513513
# Prevent other default key handling:

waypaper/changer.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import time
55

66

7-
def change_wallpaper(image_path, fill_option, color, backend, monitor, txt):
7+
def change_wallpaper(image_path, fill_option, color, backend, monitor, transition, txt):
88
"""Run a system command to change the wallpaper depending on the backend"""
99

1010
try:
@@ -43,7 +43,8 @@ def change_wallpaper(image_path, fill_option, color, backend, monitor, txt):
4343
command = ["swww", "img", image_path]
4444
command.extend(["--resize", fill])
4545
command.extend(["--fill-color", color])
46-
command.extend(["--transition-step", str(10)])
46+
command.extend(["--transition-type", transition])
47+
# command.extend(["--transition-step", str(30)])
4748
if monitor != "All":
4849
command.extend(["--outputs", monitor])
4950
subprocess.Popen(command)

waypaper/config.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from platformdirs import user_config_path, user_pictures_path, user_cache_path
88

99
from waypaper.aboutdata import AboutData
10-
from waypaper.options import FILL_OPTIONS, SORT_OPTIONS
10+
from waypaper.options import FILL_OPTIONS, SORT_OPTIONS, SWWW_TRANSITIONS
1111

1212
class Config:
1313
"""User configuration loaded from the config.ini file"""
@@ -19,6 +19,7 @@ def __init__(self):
1919
self.sort_option = "name"
2020
self.backend = "swaybg"
2121
self.color = "#ffffff"
22+
self.swww_transition = "any"
2223
self.lang = "en"
2324
self.monitors = [self.selected_monitor]
2425
self.wallpaper = []
@@ -48,6 +49,9 @@ def read(self):
4849
self.sort_option = SORT_OPTIONS[0]
4950
self.backend = config.get("Settings", "backend", fallback=self.backend)
5051
self.color = config.get("Settings", "color", fallback=self.color)
52+
self.swww_transition = config.get("Settings", "swww_transition", fallback=self.swww_transition)
53+
if self.swww_transition not in SWWW_TRANSITIONS:
54+
self.swww_transition = "any"
5155
self.lang = config.get("Settings", "language", fallback=self.lang)
5256
self.include_subfolders = config.getboolean("Settings", "subfolders", fallback=self.include_subfolders)
5357

@@ -84,6 +88,7 @@ def save(self):
8488
config.set("Settings", "sort", self.sort_option)
8589
config.set("Settings", "backend", self.backend)
8690
config.set("Settings", "color", self.color)
91+
config.set("Settings", "swww_transition", self.swww_transition)
8792
config.set("Settings", "language", self.lang)
8893
config.set("Settings", "subfolders", str(self.include_subfolders))
8994
config.set("Settings", "wallpaper", ",".join(self.wallpaper))

waypaper/options.py

+2
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@
1414
BACKEND_OPTIONS[3]: ['.gif', '.jpg', '.jpeg', '.png'],
1515
}
1616

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

0 commit comments

Comments
 (0)