Notifications#

class ignis.services.notifications.NotificationService(*args: Any, **kwargs: Any)#

A notification daemon. Allow receiving notifications and perform actions on them.

Raises:

AnotherNotificationDaemonRunningError -- If another notification daemon is already running.

Example usage:

from ignis.services.notifications import NotificationsService

notifications = NotificationsService.get_default()

notifications.connect("notified", lambda x, notification: print(notification.app_name, notification.summary))
notified(*args)#
  • Signal

Emitted when a new notification appears.

Parameters:

notification (Notification) -- The instance of the notification.

new_popup(*args)#
  • Signal

Emitted when a new popup notification appears. Only emitted if dnd is set to False.

Parameters:

notification (Notification) -- The instance of the notification.

property notifications: list[Notification]#
  • read-only

A list of all notifications.

property popups: list[Notification]#
  • read-only

A list of currently active popup notifications.

property dnd: bool#
  • read-write

Do Not Disturb mode. If set to True, the new_popup signal will not be emitted, and all new Notification instances will have popup set to False.

Default: False.

property popup_timeout: int#
  • read-write

The timeout before a popup is automatically dismissed, in milliseconds.

Default: 5000.

property max_popups_count: int#
  • read-write

The Maximum number of popups. If the length of the popups list exceeds max_popups_count, the oldest popup will be dismissed.

Default: 3.

get_notification(id: int) Notification | None#

Get Notification by ID.

Parameters:

id (int) -- The ID of the notification to get.

Return type:

Notification | None

Returns:

Notification or None

clear_all() None#

Clear all notifications.

Return type:

None

class ignis.services.notifications.Notification(dbus: DBusService, id: int, app_name: str, icon: str, summary: str, body: str, actions: list[str], urgency: int, timeout: int, time: float, popup: bool)#

A notification object. Contains data about the notification and allows performing actions.

closed()#
  • Signal

Emitted when notification has been closed.

dismissed()#
  • Signal

Emitted when notification has been dismissed.

property id: int#
  • read-only

The ID of the notification.

property app_name: str#
  • read-only

The name of the application that sent the notification.

property icon: str#
  • read-only

The icon name, path to image or None.

property summary: str#
  • read-only

The summary text of the notification, usually the title.

property body: str#
  • read-only

The body text of the notification, usually containing additional information.

property actions: list[NotificationAction]#
  • read-only

A list of actions associated with the notification.

property timeout: int#
  • read-only

The timeout for the notification. Usually equal to the popup_timeout property of the NotificationService unless the notification specifies otherwise.

property time: float#
  • read-only

Time in POSIX format when the notification was sent.

property urgency: int#
  • read-only

The urgency of the notification.

Levels:
  • -1: Not provided

  • 0: Low

  • 1: Normal

  • 2: Critical

property popup: bool#
  • read-only

Whether the notification is a popup.

property json: dict#
  • read-only

The notification data in dictionary format.

close() None#

Close the notification. This will remove it from notifications history.

Return type:

None

dismiss() None#

Dismiss the notification.

Return type:

None

class ignis.services.notifications.NotificationAction(dbus: DBusService, notification, id: str, label: str)#

A simple object that contains data about a notification action.

property id: str#
  • read-only

The ID of the action.

property label: str#
  • read-only

The label of the notification. This one should be displayed to user.

invoke() None#

Invoke this action.

Return type:

None