Compare commits

..

2 commits

Author SHA1 Message Date
Emma Nora Theuer
49c7cc9a05 Update code to reflect changes in wallman_systray.py 2024-10-16 18:41:54 +02:00
Emma Nora Theuer
e845bccdae Significantly improved code readability 2024-10-16 18:41:22 +02:00
2 changed files with 11 additions and 11 deletions

View file

@ -224,7 +224,7 @@ class WallpaperLogic(_ConfigLib):
self._notify_user()
return has_wallpaper_been_set
def run_wallpapers(self):
def schedule_wallpapers(self):
def _schedule_background_wallpapers():
from apscheduler.schedulers.background import BackgroundScheduler
scheduler = BackgroundScheduler()
@ -251,9 +251,9 @@ class WallpaperLogic(_ConfigLib):
from functools import partial
scheduler = _schedule_background_wallpapers()
menu = systray.Menu (
systray.item("Re-Set Wallpaper", partial(systray.set_wallpaper_again, callback=self.set_wallpaper_by_time)),
systray.item("Reroll Wallpapers", partial(systray.reroll_wallpapers, first_callback=self._choose_wallpaper_set, second_callback=self.set_wallpaper_by_time)),
systray.item("Quit", partial(systray.on_quit, callback=scheduler.shutdown))
systray.item("Re-Set Wallpaper", partial(systray.set_wallpaper_again, wallpaper_setter=self.set_wallpaper_by_time)),
systray.item("Reroll Wallpapers", partial(systray.reroll_wallpapers, wallpaper_chooser=self._choose_wallpaper_set, wallpaper_setter=self.set_wallpaper_by_time)),
systray.item("Quit", partial(systray.on_quit, shutdown_scheduler=scheduler.shutdown))
)
icon = systray.Icon("wallman_icon", systray.icon_image, "My Tray Icon", menu)
icon.run()

View file

@ -18,19 +18,19 @@ except ImportError:
raise
# This should always be ran with "set_wallpaper_by_time" as input!
def set_wallpaper_again(icon, item, callback):
def set_wallpaper_again(icon, item, wallpaper_setter):
logging.info("Re-Setting wallpaper due to systray input.")
callback()
wallpaper_setter()
def reroll_wallpapers(icon, item, first_callback, second_callback):
def reroll_wallpapers(icon, item, wallpaper_chooser, wallpaper_setter):
logging.info("Rerolling Wallpaper sets and resetting wallpaper due to systray input")
first_callback()
second_callback()
wallpaper_chooser()
wallpaper_setter()
# This should always be ran with "scheduler.shutdown" as input!
def on_quit(icon, item, callback):
def on_quit(icon, item, shutdown_scheduler):
logging.info("Shutting down wallman due to systray input.")
callback()
shutdown_scheduler()
icon.stop()