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 <liboxide/dbus.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