Notification API#

Name

Specification

Description

allNotifications

` ARRAY OBJECT_PATH` property (read)

List of all current applications.

unownedNotifications

` ARRAY OBJECT_PATH` property (read)

List of all applications where the owning application is no longer running.

notificationAdded

signal - (out) OBJECT_PATH

Signal sent when a notification has been added.

notificationRemoved

signal - (out) OBJECT_PATH

Signal sent when a notification has been removed.

notificationChanged

signal - (out) OBJECT_PATH

Signal sent when a notification has been modified.

add

method - (in) identifier STRING - (in) application STRING - (in) text STRING - (in) icon STRING - (out) OBJECT_PATH

Add a new notification. If the application doesn’t have permission to add the notification, or it fails to be added it will return /.

take

method - (in) identifier STRING - (out) BOOLEAN

Take ownership of a notification.

notifications

method - (out) ` ARRAY OBJECT_PATH`

List of all notifications owned by the current application.

get

method - (in) identifier STRING - (out) OBJECT_PATH

Get the object path for a notification based on it’s identifier.

Example Usage#

#include <liboxide.h>
#include "dbusservice_interface.h"
#include "notificationapi_interface.h"
#include "notification_interface.h"

using namespace codes::eeems::oxide1;

int main(int argc, char *argv[]){
    Q_UNUSED(argc);
    Q_UNUSED(argv);

    auto bus = QDBusConnection::systemBus();
    General api(OXIDE_SERVICE, OXIDE_SERVICE_PATH, bus);
    qDebug() << "Requesting notification API...";
    QDBusObjectPath path = api.requestAPI("notification");
    if(path.path() == "/"){
        qDebug() << "Unable to get notification API";
        return EXIT_FAILURE;
    }
    qDebug() << "Got the notification API!";

    Notifications notifications(OXIDE_SERVICE, path.path(), bus);
    qDebug() << "Notificaitons:" << notifications.allNotifications();
    return EXIT_SUCCESS;
}
#!/bin/bash
echo -n "Notifications: "
rot notification get notifications | jq

Notification Object#

Name

Specification

Description

identifier

STRING property (read)

Unique identifier for the notification.

application

STRING property (read/write)

Name of the application that owns this notification.

text

STRING property (read/write)

Text of the notification.

icon

STRING property (read/write)

Icon used for the notification.

changed

signal - (out) ` ARRAY{STRING VARIANT}`

Signal sent when something on the notification has changed. The first output property contains a map of changed properties and their values.

removed

signal

Signal sent when this notification has been removed.

displayed

signal

Signal sent when this notification has been displayed.

clicked

signal

Signal sent when this notification has been clicked.

display

method

Display the notification to the user. This will interrupt what the user is doing to display the text on the bottom left corner.

remove

method

Remove the notification.

click

method

Emit the clicked signal on the notification so that the owning application can handle the click.

Example Usage#

#include <QUuid>
#include <liboxide.h>
#include "dbusservice_interface.h"
#include "notificationapi_interface.h"
#include "notification_interface.h"

using namespace codes::eeems::oxide1;

int main(int argc, char *argv[]){
    Q_UNUSED(argc);
    Q_UNUSED(argv);

    auto bus = QDBusConnection::systemBus();
    General api(OXIDE_SERVICE, OXIDE_SERVICE_PATH, bus);
    qDebug() << "Requesting notification API...";
    QDBusObjectPath path = api.requestAPI("notification");
    if(path.path() == "/"){
        qDebug() << "Unable to get notification API";
        return EXIT_FAILURE;
    }
    qDebug() << "Got the notification API!";

    Notifications notifications(OXIDE_SERVICE, path.path(), bus);
    auto guid = QUuid::createUuid().toString();
    qDebug() << "Adding notification" << guid;
    path = notifications.add(guid, "codes.eeems.fret", "Hello world!", "");
    if(path.path() == "/"){
        qDebug() << "Failed to add notification";
        return EXIT_FAILURE;
    }

    Notification notification(OXIDE_SERVICE, path.path(), bus);
    qDebug() << "Displaying notification" << guid;
    notification.display().waitForFinished();
    notification.remove();
    return EXIT_SUCCESS;
}
#!/bin/bash
uuid=$(cat /proc/sys/kernel/random/uuid)
path=$(rot notification call add \
        "QString:\"$uuid\"" \
        'QString:"sample-application"' \
        'QString:"Hello world!"' \
        'QString:""' \
     | jq -cr \
     | sed 's|/codes/eeems/oxide1/||'
)
echo "Displaying notification $uuid"
rot --object Notification:$path notification call display
rot --object Notification:$path notification call remove