feat: add notifier.py for windows notifications
This commit is contained in:
26
notifier.py
Normal file
26
notifier.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
from logger import logger
|
||||||
|
|
||||||
|
try:
|
||||||
|
from plyer import notification
|
||||||
|
PLYER_AVAILABLE = True
|
||||||
|
except ImportError:
|
||||||
|
logger.warning("plyer not found. Notifications will be printed to stdout.")
|
||||||
|
PLYER_AVAILABLE = False
|
||||||
|
|
||||||
|
class Notifier:
|
||||||
|
def notify(self, title, message):
|
||||||
|
logger.info(f"Notification: {title} - {message}")
|
||||||
|
if PLYER_AVAILABLE:
|
||||||
|
try:
|
||||||
|
notification.notify(
|
||||||
|
title=title,
|
||||||
|
message=message,
|
||||||
|
app_name="Git Monitor",
|
||||||
|
# timeout=10
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Error showing notification: {e}")
|
||||||
|
else:
|
||||||
|
print(f"[{title}] {message}")
|
||||||
|
|
||||||
|
notifier = Notifier()
|
||||||
Reference in New Issue
Block a user