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.")
|
2024-10-16 16:41:22 +00:00
|
|
|
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"
|
|
|
|
)
|
2024-10-16 16:41:22 +00:00
|
|
|
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.")
|
2024-10-16 16:41:22 +00:00
|
|
|
shutdown_scheduler()
|
2024-09-01 17:27:34 +00:00
|
|
|
icon.stop()
|
|
|
|
|
|
|
|
|
2024-09-02 14:38:52 +00:00
|
|
|
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."
|
|
|
|
)
|