mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-08-04 06:36:24 +00:00
Add a sample showing on_activation event for notifications
This commit is contained in:
parent
de21e5e488
commit
67410c317f
1 changed files with 9 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue