mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-06 09:15:57 +02:00
Add a sample showing on_activation event for notifications
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user