Notifications
class NotificationCloseReason (value, names=_not_given, *values, module=None, qualname=None, type=None, start=1, boundary=None)
Section titled “ NotificationCloseReason ”Bases: Enum
A reason for which a notification was closed
member EXPIRED 1
Section titled “ EXPIRED ”member DISMISSED_BY_USER 2
Section titled “ DISMISSED_BY_USER ”member CLOSED_BY_APPLICATION 3
Section titled “ CLOSED_BY_APPLICATION ”member UNKNOWN 4
Section titled “ UNKNOWN ”class NotificationImagePixmap (raw_variant: Variant)
Section titled “ NotificationImagePixmap ”Bases: object
A class for storing image data associated with a notification
classmethod deserialize (data: tuple[int, int, int, bool, int, int, str])NotificationImagePixmap
Section titled “ deserialize ”Load image data from a serialized data tuple (using the serialize method) and return the newly created Pixmap object
- Parameters: data (tuple *[*int , int , int , bool , int , int , str ]) — the tuple which is holding the image’s data
- Returns: the newly loaded image pixmap
- Return type: NotificationImagePixmap
def as_pixbuf ()Pixbuf
Section titled “ as_pixbuf ”Load a Pixbuf variant of this pixmap
- Returns: the newly created pixbuf in which it has the contents of this pixmap
- Return type: GdkPixbuf.Pixbuf
def serialize ()tuple[int, int, int, bool, int, int, str]
Section titled “ serialize ”Serialize this pixmap image into a tuple for ease of carrying and saving
- Returns: the serialized pixmap image data
- Return type: tuple[int, int, int, bool, int, int, str]
class NotificationAction (identifier: str, label: str, parent: Notification)
Section titled “ NotificationAction ”Bases: object
A notification action that can be invoked
attribute identifier str
Section titled “ identifier ”attribute label str
Section titled “ label ”attribute parent Notification
Section titled “ parent ”def invoke ()
Section titled “ invoke ”Invoke this action
class NotificationSerializedData
Section titled “ NotificationSerializedData ”Bases: TypedDict
attribute id int
Section titled “ id ”attribute summary str
Section titled “ summary ”attribute body str
Section titled “ body ”attribute timeout int
Section titled “ timeout ”attribute urgency int
Section titled “ urgency ”attribute actions list[tuple[str, str]]
Section titled “ actions ”attribute time float
Section titled “ time ”class Notification (id: int, raw_variant: Variant, **kwargs)
Section titled “ Notification ”Bases: Service
The notification class holds all the data of a specific notification (such as actions, images and sender’s info)
Default service constructor (base constructor)
-
Parameters: **kwargs —
mapped to signal connections (e.g. on_clicked=lambda *_: … connects the given function to the signal “clicked”, notify_my_property=my_func connects the given function to the signal “notify::my-property”)
signal closed (self, reason: object)NoneType
Section titled “ closed ”signal action_invoked (self, action: str)NoneType
Section titled “ action_invoked ”property app_name str
Section titled “ app_name ”The display name of the application sent this notification
- Returns: sender’s display name
- Return type: str
property app_icon str
Section titled “ app_icon ”An optional application icon name
- Returns: sender’s named icon (or None)
- Return type: str
property summary str
Section titled “ summary ”property body str
Section titled “ body ”A multi-line body of text given by the sender (might contain markup)
- Returns: this notification’s body text
- Return type: str
property id int
Section titled “ id ”The uniuqe identifier of this notification
- Returns: this notification’s id
- Return type: int
property replaces_id int
Section titled “ replaces_id ”An optional ID of an existing notification that this notification is intended to replace
- Returns: the id of the targeted notification (or None)
- Return type: int
property timeout int
Section titled “ timeout ”Expiration timeout (in milliseconds) since the display of the notification at which the notification should automatically get closed
- Returns: timeout in milliseconds, -1 means whatever the user decides, 0 means the notification is supposed to never get closed
- Return type: int
property urgency int
Section titled “ urgency ”Urgency level of this notification
- Returns: the urgency level as an integer, 0 for low, 1 for normal, 2 for critical
- Return type: int
property actions list[NotificationAction]
Section titled “ actions ”A list of all the action this notification has
- Returns: a list of notification actions
- Return type: list[NotificationAction]
property image_pixmap NotificationImagePixmap
Section titled “ image_pixmap ”Raw image data supplied by the sender (if any)
- Returns: raw image data stored in a pixmap object
- Return type: NotificationImagePixmap
property image_file str
Section titled “ image_file ”The image file path provided by the sender for this notification (if any)
- Returns: the image file path
- Return type: str
property time float
Section titled “ time ”The Unix timestamp at which this notification was received
- Returns: Unix timestamp (seconds since epoch)
- Return type: float
property image_pixbuf Pixbuf
Section titled “ image_pixbuf ”A Pixbuf loaded from either image-pixmap or the image-file property
- Returns: the newly loaded image pixbuf
- Return type: GdkPixbuf.Pixbuf
classmethod deserialize (data: NotificationSerializedData, **kwargs)Notification
Section titled “ deserialize ”Deserialize a given serialized notification data into a newly created notification object
- Parameters: data (NotificationSerializedData) — the serialized data to consume and covert to an object
- Returns: the newly created notification object
- Return type: Notification
def serialize ()NotificationSerializedData
Section titled “ serialize ”Serialize this notification into a dictionary that can easily get converted into JSON
- Returns: the serialized notification data (dict)
- Return type: NotificationSerializedData
def invoke_action (action: str)
Section titled “ invoke_action ”Invoke an action via its name
def close (reason: Literal['expired', 'dismissed-by-user', 'closed-by-application', 'unknown'] | NotificationCloseReason = NotificationCloseReason.DISMISSED_BY_USER)
Section titled “ close ”Close this notification and notify the sender with a reason
- Parameters: reason (Literal [ “expired” , “dismissed-by-user” , “closed-by-application” , “unknown” ] | NotificationCloseReason , optional) — the reason behind the close of this notification, defaults to NotificationCloseReason.DISMISSED_BY_USER
class Notifications (**kwargs)
Section titled “ Notifications ”Bases: Service
A server for watching in-coming notifications from running applications, in order for it to work, other notification daemons must be NOT running on the system
Default service constructor (base constructor)
-
Parameters: **kwargs —
mapped to signal connections (e.g. on_clicked=lambda *_: … connects the given function to the signal “clicked”, notify_my_property=my_func connects the given function to the signal “notify::my-property”)
signal changed (self)NoneType
Section titled “ changed ”signal notification_added (self, notification_id: int)NoneType
Section titled “ notification_added ”signal notification_removed (self, notification_id: int)NoneType
Section titled “ notification_removed ”signal notification_closed (self, notification_id: int, reason: object)NoneType
Section titled “ notification_closed ”property notifications dict[int, Notification]
Section titled “ notifications ”A list of all the notifications received by this server
- Returns: the list of notifications
- Return type: dict[int, Notification]
def new_notification_id ()int
Section titled “ new_notification_id ”Get the next notification id and increase the internal counter
- Returns: the next id
- Return type: int
def get_notification_from_id (notification_id: int)Notification | None
Section titled “ get_notification_from_id ”Lookup a notification via its identifier
- Parameters: notification_id (int) — the notification’s id (gotten from the notification-added signal)
- Returns: the desired notification object (if found)
- Return type: Notification | None
def invoke_notification_action (notification_id: int, action: str)
Section titled “ invoke_notification_action ”Invoke a named action on a notification
- Parameters:
- notification_id (int) — the notification id of in which the action should be triggered
- action (str) — the name of the action
def remove_notification (notification_id: int)
Section titled “ remove_notification ”Remove a notification (without closing it) from the server
- Parameters: notification_id (int) — the id of the notification
def close_notification (notification_id: int, reason: NotificationCloseReason = NotificationCloseReason.DISMISSED_BY_USER)
Section titled “ close_notification ”Close a notification and remove it from the server
- Parameters:
- notification_id (int) — the id of the notification
- reason (NotificationCloseReason , optional) — the reason behind this notification begin closed, defaults to NotificationCloseReason.DISMISSED_BY_USER
def serialize ()list[NotificationSerializedData]
Section titled “ serialize ”Similar to Notification.serialize but it serializes all the notifications in the server instead
- Returns: a list with all the serialized notifications in this server
- Return type: list[NotificationSerializedData]
def deserialize (data: list[NotificationSerializedData])
Section titled “ deserialize ”Load a list of serialized notifications data
- Parameters: data (list *[*NotificationSerializedData ]) — the list with serialized notifications