notify_rs

Classes:

Notification()

Desktop notification.

NotificationHandle

A handle to a shown notification.

ServerInformation

Return value of get_server_information().

Functions:

get_capabilities()

Get list of all capabilities of the running notification server.

get_server_information()

Returns a struct containing ServerInformation.

class Notification

Bases: object

Desktop notification.

Most fields are empty by default, only appname is initialized with the name of the current executable. The appname is used by some desktop environments to group notifications.

Methods:

appname(appname)

Overwrite the appname field.

auto_icon()

Set the icon field automatically.

body(body)

Set the content of the body field.

finalize()

Finalizes a Notification.

get_appname()

Filled by default with executable name.

get_body()

Multiple lines possible, may support simple markup, check out get_capabilities() -> body-markup and body-hyperlinks.

get_icon()

Use a file:// URI or a name in an icon theme.

get_subtitle()

Subtitle for macOS

get_summary()

Single line to summarize the content.

get_timeout()

Lifetime of the Notification in ms.

icon(icon)

Set the icon field.

id(id)

Sets the notification's ID.

image_path(path)

Path to an image to use in the image_data hint.

show()

Shows the notification.

subtitle(subtitle)

Set the subtitle.

summary(summary)

Set the summary.

timeout(timeout)

Set the timeout.

urgency(urgency)

Controls whether the notification is shown to the user while e.g.

appname(appname)

Overwrite the appname field.

Return type

str

auto_icon()

Set the icon field automatically.

This looks at your binary’s name and uses it to set the icon.

Note

macOS does not have support manually setting the icon

Return type

Notification

body(body)

Set the content of the body field.

Multiline textual content of the notification. Each line should be treated as a paragraph. Simple html markup should be supported, depending on the server implementation.

Parameters

bodystr

Return type

Notification

finalize()

Finalizes a Notification.

Return type

Notification

get_appname()

Filled by default with executable name.

Return type

str

get_body()

Multiple lines possible, may support simple markup, check out get_capabilities() -> body-markup and body-hyperlinks.

Return type

str

get_icon()

Use a file:// URI or a name in an icon theme.

Return type

str

get_subtitle()

Subtitle for macOS

get_summary()

Single line to summarize the content.

Return type

str

get_timeout()

Lifetime of the Notification in ms. Often not respected by server, sorry.

Return type

int

icon(icon)

Set the icon field.

You can use common icon names here; usually those in /usr/share/icons can all be used. You can also use an absolute path to a file.

Note

macOS does not have support manually setting the icon

Parameters

iconstr

Return type

Notification

id(id)

Sets the notification’s ID.

Parameters

bodyint

Return type

Notification

image_path(path)

Path to an image to use in the image_data hint.

Return type

Notification

show()

Shows the notification.

Return type

Notification

subtitle(subtitle)

Set the subtitle.

This is only useful on macOS; It’s not part of the XDG specification.

Return type

str

summary(summary)

Set the summary.

Often acts as title of the notification. For more elaborate content use the body field.

Return type

str

timeout(timeout)

Set the timeout.

Parameters

bodyint

Return type

Notification

urgency(urgency)

Controls whether the notification is shown to the user while e.g. watching a video.

Parameters

bodyint

Return type

Notification

class NotificationHandle

Bases: object

A handle to a shown notification.

Methods:

appname(appname)

Overwrite the appname field.

auto_icon()

Set the icon field automatically.

body(body)

Set the content of the body field.

finalize()

Finalizes a Notification.

get_appname()

Filled by default with executable name.

get_body()

Multiple lines possible, may support simple markup, check out get_capabilities() -> body-markup and body-hyperlinks.

get_icon()

Use a file:// URI or a name in an icon theme.

get_subtitle()

Subtitle for macOS

get_summary()

Single line to summarize the content.

get_timeout()

Lifetime of the Notification in ms.

icon(icon)

Set the icon field.

image_path(path)

Path to an image to use in the image_data hint.

show()

Shows the notification.

subtitle(subtitle)

Set the subtitle.

summary(summary)

Set the summary.

timeout(timeout)

Set the timeout.

urgency(urgency)

Controls whether the notification is shown to the user while e.g.

appname(appname)

Overwrite the appname field.

Return type

str

auto_icon()

Set the icon field automatically.

This looks at your binary’s name and uses it to set the icon.

Note

macOS does not have support manually setting the icon

Return type

Notification

body(body)

Set the content of the body field.

Multiline textual content of the notification. Each line should be treated as a paragraph. Simple html markup should be supported, depending on the server implementation.

Parameters

bodystr

Return type

Notification

finalize()

Finalizes a Notification.

Return type

Notification

get_appname()

Filled by default with executable name.

Return type

str

get_body()

Multiple lines possible, may support simple markup, check out get_capabilities() -> body-markup and body-hyperlinks.

Return type

str

get_icon()

Use a file:// URI or a name in an icon theme.

Return type

str

get_subtitle()

Subtitle for macOS

get_summary()

Single line to summarize the content.

Return type

str

get_timeout()

Lifetime of the Notification in ms. Often not respected by server, sorry.

Return type

int

icon(icon)

Set the icon field.

You can use common icon names here; usually those in /usr/share/icons can all be used. You can also use an absolute path to a file.

Note

macOS does not have support manually setting the icon

Parameters

iconstr

Return type

Notification

image_path(path)

Path to an image to use in the image_data hint.

Return type

Notification

show()

Shows the notification.

On Windows this returns the Notification; on Unix and other OSes it returns a NotificationHandle, which can be used to modify the notification later.

subtitle(subtitle)

Set the subtitle.

This is only useful on macOS; It’s not part of the XDG specification.

Return type

str

summary(summary)

Set the summary.

Often acts as title of the notification. For more elaborate content use the body field.

Return type

str

timeout(timeout)

Set the timeout.

Parameters

bodyint

Return type

Notification

urgency(urgency)

Controls whether the notification is shown to the user while e.g. watching a video.

Parameters

bodyint

Return type

Notification

class ServerInformation

Bases: object

Return value of get_server_information().

Attributes:

name

The product name of the server.

spec_version

The specification version the server is compliant with.

vendor

The vendor name.

version

The server's version string.

name: int

The product name of the server.

spec_version: int

The specification version the server is compliant with.

vendor: int

The vendor name.

version: int

The server’s version string.

get_capabilities()

Get list of all capabilities of the running notification server.

get_server_information()

Returns a struct containing ServerInformation.

This struct contains name, vendor, version and spec_version of the notification server running.

TIMEOUT_NEVER = -2

Type:    int

TIMEOUT_DEFAULT = -1

Type:    int

URGENCY_LOW = 0

Type:    int

URGENCY_NORMAL = 1

Type:    int

URGENCY_CRITICAL = 2

Type:    int