Wallman/wallman/wallman_systray.py

43 lines
1.5 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
# Use logger that is also in wallman_lib
logger = logging.getLogger("wallman")
try:
from PIL import Image
except ImportError:
logging.error("Couldn't import PIL, wallman will launch without a systray.")
print("Couldn't import PIL, wallman will launch without a systray.")
raise
try:
from pystray import Icon, MenuItem as item, Menu
except ImportError:
logging.error("Couldn't import pystray, wallman will launch without a systray.")
print("Couldn't import pystray, wallman will launch without a systray.")
raise
# This should always be ran with "set_wallpaper_by_time" as input!
def set_wallpaper_again(icon, item, wallpaper_setter):
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
def reroll_wallpapers(icon, item, wallpaper_chooser, wallpaper_setter):
2024-09-01 17:27:34 +00:00
logging.info("Rerolling Wallpaper sets and resetting wallpaper due to systray input")
wallpaper_chooser()
wallpaper_setter()
2024-09-01 17:27:34 +00:00
# This should always be ran with "scheduler.shutdown" as input!
def on_quit(icon, item, shutdown_scheduler):
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:
2024-12-30 02:39:07 +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.")