mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-08-27 03:42:49 +00:00
Allow multiple types per notification
This commit is contained in:
parent
4bc532a2d0
commit
212d7accfc
4 changed files with 25 additions and 18 deletions
|
|
@ -67,8 +67,11 @@ by means of two keys ``f`` which is the application name and ``t``
|
|||
which is the notification type. These are free form keys, they can contain
|
||||
any values, their purpose is to allow users to easily filter out
|
||||
notifications they do not want. Both keys must have :ref:`base64`
|
||||
encoded UTF-8 text as their values. Terminals can then present UI to users
|
||||
to allow them to filter out notifications from applications they do not want.
|
||||
encoded UTF-8 text as their values. The ``t`` key can be specified multiple
|
||||
times, as notifications can have more than one type. See the `freedesktop.org
|
||||
spec
|
||||
<https://specifications.freedesktop.org/notification-spec/notification-spec-latest.html#categories>`__
|
||||
for examples of notification types.
|
||||
|
||||
.. note::
|
||||
The application name should generally be set to the filename of the
|
||||
|
|
@ -273,7 +276,7 @@ Key Value Default Description
|
|||
``e`` ``0`` or ``1`` ``0`` If set to ``1`` means the payload is :ref:`base64` encoded UTF-8,
|
||||
otherwise it is plain UTF-8 text with no C0 control codes in it
|
||||
|
||||
``f`` :ref:`base64` ``unset`` The name of the application sending the notification. Can be used to filter out notifications.
|
||||
``f`` :ref:`base64` ``unset`` The name of the application sending the notification. Can be used to filter out notifications.
|
||||
encoded UTF-8
|
||||
application name
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ def log_notification(nc: NotificationCommand) -> None:
|
|||
print(f'title: {nc.title}', file=log)
|
||||
print(f'body: {nc.body}', file=log)
|
||||
print(f'app: {nc.application_name}', file=log)
|
||||
print(f'type: {nc.notification_type}', file=log)
|
||||
print(f'types: {nc.notification_types}', file=log)
|
||||
print('\n', file=log)
|
||||
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ def main(nc: NotificationCommand) -> bool:
|
|||
# run a script if this notification is from myapp and has
|
||||
# type foo, passing in the title and body as command line args
|
||||
# to the script.
|
||||
if nc.application_name == 'myapp' and nc.notification_type == 'foo':
|
||||
if nc.application_name == 'myapp' and 'foo' in nc.notification_types:
|
||||
subprocess.Popen(['/path/to/my/script', nc.title, nc.body])
|
||||
|
||||
# do some arbitrary actions when this notification is activated
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue