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 "dbussettings.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 "dbussettings.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

Power API#

Name

Specification

Description

state

INT32 property (read/write)

Currently requested power state. Possible values: - 0 Normal - 1 Power Saving

batteryState

INT32 property (read)

Current battery state. - 0 Unknown - 1 Charging - 2 Discharging - 3 Not Present

batteryLevel

INT32 property (read)

Current battery percentage.

batteryTemperature

INT32 property (read)

Current battery temperature in Celsius.

chargerState

INT32 property (read)

Current charger state. - 0 Unknown - 1 Connected - 2 Not Connected

stateChanged

signal - (out) INT32

Signal sent when the requested power state has changed.

batteryStateChanged

signal - (out) INT32

Signal sent when the battery state has changed.

batteryLevelChanged

signal - (out) INT32

Signal sent when the battery level has changed.

batte ryTemperatureChanged

signal - (out) INT32

Signal sent when the battery temperature has changed.

chargerStateChanged

signal - (out) INT32

Signal sent when the charger state has changed.

batteryWarning

signal

Signal sent when a battery warning has been detected.

batteryAlert

signal

Signal sent when a battery alert has been detected.

chargerWarning

signal

Signal sent when a charger warning has been detected.

Example Usage#

#include "dbussettings.h"
#include "dbusservice_interface.h"
#include "powerapi_interface.h"

using namespace codes::eeems::oxide1;

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

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

    Power power(OXIDE_SERVICE, path.path(), bus);
    qDebug() << "Logging battery level:";
    qDebug() << power.batteryLevel();
    QObject::connect(&power, &Power::batteryLevelChanged, [](int batteryLevel){
        qDebug() << batteryLevel;
    });
    return app.exec();
}
#!/bin/bash
echo "Logging battery level:"
rot power get batteryLevel
rot power listen batteryLevelChanged