_protocol
_protocol
¶
PEP 544 protocol defining the Notifier interface.
Notifier
¶
Bases: Protocol
Structural type for desktop notification backends.
Implementations must provide notify, on_action, close, and
disconnect. DbusNotifier talks to a real session bus;
NullNotifier silently discards everything for headless environments.
notify(summary, body='', *, actions=(), timeout_ms=-1, hints=None, replaces_id=0, app_icon='')
async
¶
Send a desktop notification.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
summary
|
str
|
Notification title. |
required |
body
|
str
|
Optional body text. |
''
|
actions
|
Sequence[tuple[str, str]]
|
|
()
|
timeout_ms
|
int
|
Expiration hint in milliseconds ( |
-1
|
hints
|
Mapping[str, Any] | None
|
Freedesktop hint dict (values are |
None
|
replaces_id
|
int
|
Replace an existing notification in-place. |
0
|
app_icon
|
str
|
Icon name or |
''
|
Returns:
| Type | Description |
|---|---|
int
|
Server-assigned notification ID ( |
Source code in src/terok_dbus/_protocol.py
on_action(notification_id, callback)
async
¶
Register a callback for when the user clicks an action button.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
notification_id
|
int
|
ID returned by |
required |
callback
|
Callable[[str], None]
|
Called with the |
required |
Source code in src/terok_dbus/_protocol.py
close(notification_id)
async
¶
Close an active notification.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
notification_id
|
int
|
ID returned by |
required |