Wallman/wallman/wallman_systray.py

41 lines
1.2 KiB
Python
Raw Normal View History

2024-12-30 02:39:07 +00:00
from os import chdir
2024-09-01 17:27:34 +00:00
import logging
2025-02-27 14:53:46 +00:00
from PIL import Image
2025-02-27 16:28:32 +00:00
from pystray import Icon, MenuItem as item, Menu # noqa: F401
2024-09-01 17:27:34 +00:00
# Use logger that is also in wallman_lib
logger = logging.getLogger("wallman")
2025-02-27 16:28:32 +00:00
2024-09-01 17:27:34 +00:00
# This should always be ran with "set_wallpaper_by_time" as input!
2025-02-27 16:28:32 +00:00
def set_wallpaper_again(icon, item, wallpaper_setter): # noqa: F811
2024-09-01 17:27:34 +00:00
logging.info("Re-Setting wallpaper due to systray input.")
wallpaper_setter()
2024-09-01 17:27:34 +00:00
2025-02-27 16:28:32 +00:00
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()
2024-09-01 17:27:34 +00:00
2025-02-27 16:28:32 +00:00
2024-09-01 17:27:34 +00:00
# This should always be ran with "scheduler.shutdown" as input!
2025-02-27 16:28:32 +00:00
def on_quit(icon, item, shutdown_scheduler): # noqa: F811
2024-09-01 17:27:34 +00:00
logging.info("Shutting down wallman due to systray input.")
shutdown_scheduler()
2024-09-01 17:27:34 +00:00
icon.stop()
chdir("/etc/wallman/icons/")
2024-09-01 17:27:34 +00:00
try:
2024-12-30 02:39:07 +00:00
icon_image: Image.Image = Image.open("systrayIcon.jpg")
2024-09-01 17:27:34 +00:00
except FileNotFoundError:
2025-02-27 16:28:32 +00:00
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."
)