Wallman/wallman/wallman_systray.py
2025-02-27 15:53:46 +01:00

30 lines
1.2 KiB
Python

from os import chdir
import logging
from PIL import Image
from pystray import Icon, MenuItem as item, Menu # noqa: F401
# Use logger that is also in wallman_lib
logger = logging.getLogger("wallman")
# This should always be ran with "set_wallpaper_by_time" as input!
def set_wallpaper_again(icon, item, wallpaper_setter): # noqa: F811
logging.info("Re-Setting wallpaper due to systray input.")
wallpaper_setter()
def reroll_wallpapers(icon, item, wallpaper_chooser, wallpaper_setter): # noqa: F811
logging.info("Rerolling Wallpaper sets and resetting wallpaper due to systray input")
wallpaper_chooser()
wallpaper_setter()
# This should always be ran with "scheduler.shutdown" as input!
def on_quit(icon, item, shutdown_scheduler): # noqa: F811
logging.info("Shutting down wallman due to systray input.")
shutdown_scheduler()
icon.stop()
chdir("/etc/wallman/icons/")
try:
icon_image: Image.Image = Image.open("systrayIcon.jpg")
except FileNotFoundError:
logger.error("/etc/wallman/icons/systrayIcon.jpg has not been found, wallman will launch without a systray.")
print("ERROR: /etc/wallman/icons/systrayIcon.jpg has not been found, wallman will launch without a systray.")