Notifications
import { Aside } from “@astrojs/starlight/components”; import TypeSignature from “@components/TypeSignature.astro”;
<TypeSignature typeName={ “NotificationCloseReason” } typePrefix={ “class” } typeArgList={ ”(*values)” }> NotificationCloseReason
Bases: Enum
A reason for which a notification was closed
<TypeSignature typeName={ “EXPIRED” } typePrefix={ “member” } returnType={ “1” }> EXPIRED
<TypeSignature typeName={ “DISMISSED_BY_USER” } typePrefix={ “member” } returnType={ “2” }> DISMISSED_BY_USER
<TypeSignature typeName={ “CLOSED_BY_APPLICATION” } typePrefix={ “member” } returnType={ “3” }> CLOSED_BY_APPLICATION
<TypeSignature typeName={ “UNKNOWN” } typePrefix={ “member” } returnType={ “4” }> UNKNOWN
<TypeSignature typeName={ “NotificationImagePixmap” } typePrefix={ “class” } typeArgList={ “(raw_variant: Variant)” }> NotificationImagePixmap
Bases: object
A class for storing image data associated with a notification
<TypeSignature typeName={ “deserialize” } typePrefix={ “classmethod” } typeArgList={ “(data: tuple[int, int, int, bool, int, int, str])” } returnType={ “NotificationImagePixmap” }> 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
<TypeSignature typeName={ “as_pixbuf” } typePrefix={ “def” } typeArgList={ ”()” } returnType={ “Pixbuf” }> 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
<TypeSignature typeName={ “serialize” } typePrefix={ “def” } typeArgList={ ”()” } returnType={ “tuple[int, int, int, bool, int, int, str]” }> 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]
<TypeSignature typeName={ “NotificationAction” } typePrefix={ “class” } typeArgList={ “(identifier: str, label: str, parent: Notification)” }> NotificationAction
Bases: object
A notification action that can be invoked
<TypeSignature typeName={ “identifier” } typePrefix={ “attribute” } returnType={ “str” }> identifier
<TypeSignature typeName={ “label” } typePrefix={ “attribute” } returnType={ “str” }> label
<TypeSignature typeName={ “parent” } typePrefix={ “attribute” } returnType={ “Notification” }> parent
<TypeSignature typeName={ “invoke” } typePrefix={ “def” } typeArgList={ ”()” }> invoke
Invoke this action
<TypeSignature typeName={ “NotificationSerializedData” } typePrefix={ “class” }> NotificationSerializedData
Bases: TypedDict
<TypeSignature typeName={ “id” } typePrefix={ “attribute” } returnType={ “int” }> id
<TypeSignature typeName={ “summary” } typePrefix={ “attribute” } returnType={ “str” }> summary
<TypeSignature typeName={ “body” } typePrefix={ “attribute” } returnType={ “str” }> body
<TypeSignature typeName={ “timeout” } typePrefix={ “attribute” } returnType={ “int” }> timeout
<TypeSignature typeName={ “urgency” } typePrefix={ “attribute” } returnType={ “int” }> urgency
<TypeSignature typeName={ “actions” } typePrefix={ “attribute” } returnType={ “list[tuple[str, str]]” }> actions
<TypeSignature typeName={ “Notification” } typePrefix={ “class” } typeArgList={ “(id: int, raw_variant: Variant, **kwargs)” }> 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”)
<TypeSignature typeName={ “closed” } typePrefix={ “signal” } typeArgList={ “(self, reason: object)” } returnType={ “NoneType” }> closed
<TypeSignature typeName={ “action_invoked” } typePrefix={ “signal” } typeArgList={ “(self, action: str)” } returnType={ “NoneType” }> action_invoked
<TypeSignature typeName={ “app_name” } typePrefix={ “property” } returnType={ “str” }> app_name
The display name of the application sent this notification
- Returns: sender’s display name
- Return type: str
<TypeSignature typeName={ “app_icon” } typePrefix={ “property” } returnType={ “str” }> app_icon
An optional application icon name
- Returns: sender’s named icon (or None)
- Return type: str
<TypeSignature typeName={ “summary” } typePrefix={ “property” } returnType={ “str” }> summary
<TypeSignature typeName={ “body” } typePrefix={ “property” } returnType={ “str” }> body
A multi-line body of text given by the sender (might contain markup)
- Returns: this notification’s body text
- Return type: str
<TypeSignature typeName={ “id” } typePrefix={ “property” } returnType={ “int” }> id
The uniuqe identifier of this notification
- Returns: this notification’s id
- Return type: int
<TypeSignature typeName={ “replaces_id” } typePrefix={ “property” } returnType={ “int” }> replaces_id
An optional ID of an existing notification that this notification is intended to replace
- Returns: the id of the targetted notification (or None)
- Return type: int
<TypeSignature typeName={ “timeout” } typePrefix={ “property” } returnType={ “int” }> 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
<TypeSignature typeName={ “urgency” } typePrefix={ “property” } returnType={ “int” }> 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
<TypeSignature typeName={ “actions” } typePrefix={ “property” } returnType={ “list[NotificationAction]” }> actions
A list of all the action this notification has
- Returns: a list of notification actions
- Return type: list[NotificationAction]
<TypeSignature typeName={ “image_pixmap” } typePrefix={ “property” } returnType={ “NotificationImagePixmap” }> image_pixmap
Raw image data supplied by the sender (if any)
- Returns: raw image data stored in a pixmap object
- Return type: NotificationImagePixmap
<TypeSignature typeName={ “image_file” } typePrefix={ “property” } returnType={ “str” }> image_file
The image file path provided by the sender for this notification (if any)
- Returns: the image file path
- Return type: str
<TypeSignature typeName={ “image_pixbuf” } typePrefix={ “property” } returnType={ “Pixbuf” }> image_pixbuf
A Pixbuf loaded from either image-pixmap or the image-file property
- Returns: the newly loaded image pixbuf
- Return type: GdkPixbuf.Pixbuf
<TypeSignature typeName={ “deserialize” } typePrefix={ “classmethod” } typeArgList={ “(data: NotificationSerializedData, **kwargs)” } returnType={ “Notification” }> 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 objet
- Return type: Notification
<TypeSignature typeName={ “serialize” } typePrefix={ “def” } typeArgList={ ”()” } returnType={ “NotificationSerializedData” }> serialize
Serialize this notification into a dictionary that can easily get converted into JSON
- Returns: the serialized notification data (dict)
- Return type: NotificationSerializedData
<TypeSignature typeName={ “invoke_action” } typePrefix={ “def” } typeArgList={ “(action: str)” }> invoke_action
Invoke an action via its name
<TypeSignature typeName={ “close” } typePrefix={ “def” } typeArgList={ “(reason: Literal[‘expired’, ‘dismissed-by-user’, ‘closed-by-application’, ‘unknown’] | NotificationCloseReason = NotificationCloseReason.DISMISSED_BY_USER)” }> 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
<TypeSignature typeName={ “Notifications” } typePrefix={ “class” } typeArgList={ ”(**kwargs)” }> 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”)
<TypeSignature typeName={ “changed” } typePrefix={ “signal” } typeArgList={ “(self)” } returnType={ “NoneType” }> changed
<TypeSignature typeName={ “notification_added” } typePrefix={ “signal” } typeArgList={ “(self, notification_id: int)” } returnType={ “NoneType” }> notification_added
<TypeSignature typeName={ “notification_removed” } typePrefix={ “signal” } typeArgList={ “(self, notification_id: int)” } returnType={ “NoneType” }> notification_removed
<TypeSignature typeName={ “notification_closed” } typePrefix={ “signal” } typeArgList={ “(self, notification_id: int, reason: object)” } returnType={ “NoneType” }> notification_closed
<TypeSignature typeName={ “notifications” } typePrefix={ “property” } returnType={ “dict[int, Notification]” }> notifications
A list of all the notifications received by this server
- Returns: the list of notifications
- Return type: dict[int, Notification]
<TypeSignature typeName={ “new_notification_id” } typePrefix={ “def” } typeArgList={ ”()” } returnType={ “int” }> new_notification_id
Get the next notification id and increase the internal counter
- Returns: the next id
- Return type: int
<TypeSignature typeName={ “get_notification_from_id” } typePrefix={ “def” } typeArgList={ “(notification_id: int)” } returnType={ “Notification | None” }> 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
<TypeSignature typeName={ “invoke_notification_action” } typePrefix={ “def” } typeArgList={ “(notification_id: int, action: str)” }> 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
<TypeSignature typeName={ “remove_notification” } typePrefix={ “def” } typeArgList={ “(notification_id: int)” }> remove_notification
Remove a notification (without closing it) from the server
- Parameters: notification_id (int) — the id of the notification
<TypeSignature typeName={ “close_notification” } typePrefix={ “def” } typeArgList={ “(notification_id: int, reason: NotificationCloseReason = NotificationCloseReason.DISMISSED_BY_USER)” }> 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
<TypeSignature typeName={ “serialize” } typePrefix={ “def” } typeArgList={ ”()” } returnType={ “list[NotificationSerializedData]” }> 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]
<TypeSignature typeName={ “deserialize” } typePrefix={ “def” } typeArgList={ “(data: list[NotificationSerializedData])” }> deserialize
Load a list of serialized notifications data
- Parameters: data (list *[*NotificationSerializedData ]) — the list with serialized notifications