desktop_notifier.dbus

Notification backend for Linux. Includes an implementation to send desktop notifications over Dbus. Responding to user interaction with a notification requires a running asyncio event loop.

Module Contents

Classes

DBusDesktopNotifier

DBus notification backend for Linux

class desktop_notifier.dbus.DBusDesktopNotifier(app_name='Python', notification_limit=None)[source]

Bases: desktop_notifier.base.DesktopNotifierBase

DBus notification backend for Linux

This implements the org.freedesktop.Notifications standard. The DBUS connection is created in a thread with a running asyncio loop to handle clicked notifications.

Parameters:
  • app_name (str) – The name of the app. If it matches the application name in an existing desktop entry, the icon from that entry will be used by default.

  • app_icon – The default icon to use for notifications. Will take precedence over any icon from the desktop file. Should be a URI or a name in a freedesktop.org-compliant icon theme.

  • notification_limit (int | None) – Maximum number of notifications to keep in the system’s notification center.

_to_native_urgency[source]
async request_authorisation()[source]

Request authorisation to send notifications.

Returns:

Whether authorisation has been granted.

Return type:

bool

async has_authorisation()[source]

Whether we have authorisation to send notifications.

Return type:

bool

async _init_dbus()[source]
Return type:

dbus_next.aio.ProxyInterface

async _send(notification, notification_to_replace)[source]

Asynchronously sends a notification via the Dbus interface.

Parameters:
Return type:

int

async _clear(notification)[source]

Asynchronously removes a notification from the notification center

Parameters:

notification (desktop_notifier.base.Notification)

Return type:

None

async _clear_all()[source]

Asynchronously clears all notifications from notification center

Return type:

None

_on_action(nid, action_key)[source]

Called when the user performs a notification action. This will invoke the handler callback.

Parameters:
  • nid (int) – The platform’s notification ID as an integer.

  • action_key (str) – A string identifying the action to take. We choose those keys ourselves when scheduling the notification.

Return type:

None

_on_closed(nid, reason)[source]

Called when the user closes a notification. This will invoke the registered callback.

Parameters:
  • nid (int) – The platform’s notification ID as an integer.

  • reason (int) – An integer describing the reason why the notification was closed.

Return type:

None