_notifier
_notifier
¶
Desktop notifier backed by dbus-fast and the freedesktop Notifications spec.
DbusNotifier(app_name='terok')
¶
Send desktop notifications over the D-Bus session bus.
The connection is established lazily on the first notify call.
Action callbacks are dispatched from the ActionInvoked signal;
stale callbacks are cleaned up automatically on NotificationClosed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app_name
|
str
|
Application name sent with every notification. |
'terok'
|
Initialise with the given application name.
Source code in src/terok_dbus/_notifier.py
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 should be |
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/_notifier.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/_notifier.py
close(notification_id)
async
¶
Close an active notification.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
notification_id
|
int
|
ID returned by |
required |
Source code in src/terok_dbus/_notifier.py
disconnect()
async
¶
Tear down the session-bus connection.