From 67410c317ff61a7890c645ff1e5cb1a9dea8bbe5 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 28 Jul 2024 08:46:31 +0530 Subject: [PATCH] Add a sample showing on_activation event for notifications --- docs/notifications.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/notifications.py b/docs/notifications.py index 215bae805..218af47aa 100644 --- a/docs/notifications.py +++ b/docs/notifications.py @@ -18,6 +18,12 @@ def log_notification(nc: NotificationCommand) -> None: print('\n', file=log) +def on_notification_activated(nc: NotificationCommand) -> None: + # do something when this notification is activated (clicked on) + # remember to assign this to the on_activation field in main() + pass + + def main(nc: NotificationCommand) -> bool: ''' This function should return True to filter out the notification @@ -45,5 +51,8 @@ def main(nc: NotificationCommand) -> bool: if nc.application_name == 'myapp' and nc.notification_type == 'foo': subprocess.Popen(['/path/to/my/script', nc.title, nc.body]) + # do some arbitrary actions when this notification is activated + nc.on_activation = on_notification_activated + # dont filter out this notification return False