API Reference

Note

For an example see the Introduction.

kitsiso.send_notification(summary, body=None, *, app_name=None, icon=None, urgency=Urgency.NORMAL, timeout=- 1)[source]

Send a simple notification.

This function does not instantiate Notifier. It connects to the D-Bus on each call and disconnects after the notification was sent.

Parameters
  • summary (str) – a single line overview

  • body (str) – multi-line body of text

  • app_name (str) – the application name

  • icon (str) – path to notification icon

  • urgency (Urgency) – urgency level

  • timeout (int) – notification timeout in seconds, NO_TIMEOUT or DEFAULT_TIMEOUT

class kitsiso.Notifier(app_name=None, app_icon=None, bus=None)[source]

Class for sending notifications and handling actions and close events.

If bus=None a bus object will be created and connected. It can be closed with quit().

Parameters
  • app_name (str) – the application name

  • app_icon (str) – path to default notification icon

  • bus (dcar.Bus) – a bus object

quit()[source]

Close D-Bus connection.

If a dcar.Bus object was passed in on instantiation as the bus parameter, this method does nothing.

get_capabilities()[source]

Get server capabilities.

Returns

list with server capabilities

Return type

list[str]

get_server_information()[source]

Get server information.

Returns

(name, vendor, version, spec_version)

Return type

tuple(str)

notify(noti)[source]

Send notification.

Parameters

noti (Notification) – the notification

close(noti)[source]

Close notification.

Parameters

noti (Notification) – the notification

kitsiso.DEFAULT_TIMEOUT

Expiration timeout depends on the settings of the notification server. It may vary for the type of notification.

kitsiso.NO_TIMEOUT

Never expire.

class kitsiso.Urgency(value)[source]

Urgency levels for notifications: LOW, NORMAL, CRITICAL.

class kitsiso.Notification(summary, body=None, *, icon=None, urgency=Urgency.NORMAL, timeout=- 1)[source]

Class for a notification.

An instance of this class has the following r/w attributes:

  • summary

  • body

  • icon

  • urgency

  • timeout

Parameters
  • summary (str) – a single line overview

  • body (str) – multi-line body of text

  • icon (str) – path to notification icon

  • urgency (Urgency) – urgency level

  • timeout (int) – notification timeout in seconds, NO_TIMEOUT or DEFAULT_TIMEOUT

add_action(key, name, func, args=(), kwargs={})[source]

Add an action.

An action is mostly shown as a button in the notification.

Parameters
  • key (str) – must be unique for one notification

  • name (str) – will be shown in the notification

  • func (callable or None) – callback function func(*args, **kwargs) (should return quickly)

  • args (tuple) – arguments for the callback function

  • kwargs (dict) – keyword arguments for the callback function

del_action(key)[source]

Delete an action.

clear_actions()[source]

Clear all actions.

add_hint(name, signature, value)[source]

Add a hint.

Hints are defined in the specification.

The urgency hint will be ignored (use the parameter or the attribute urgency).

The signature must be given as defined in the D-Bus specification:

Type

Code

boolean

b

byte

y

int

i

string

s

Parameters
  • name (str) – name of the hint

  • signature (str) – D-Bus signature of the value type

  • value – the value

del_hint(name)[source]

Delete a hint.

clear_hints()[source]

Clear all hints.

closed(func, args=(), kwargs={})[source]

Set a function that is envoked when the notification is closed.

The the first argument to the function func is of type int and indicates the reason the notification was closed:

1

the notification expired

2

the notification was dismissed by the user

3

the notification was closed with Notifier.close()

4

undefined/reserved reasons

Parameters
  • func – the function func(reason, *args, **kwargs) (should return quickly)

  • args (tuple) – arguments for the function

  • kwargs (dict) – keyword arguments for the function

copy()[source]

Make a copy of this notification.