Power API#
Name |
Specification |
Description |
---|---|---|
state |
|
Currently requested
power state.
Possible values:
- |
batteryState |
|
Current battery
state.
- |
batteryLevel |
|
Current battery percentage. |
batteryTemperature |
|
Current battery temperature in Celsius. |
chargerState |
|
Current charger
state.
- |
stateChanged |
signal
|
Signal sent when the requested power state has changed. |
batteryStateChanged |
signal
|
Signal sent when the battery state has changed. |
batteryLevelChanged |
signal
|
Signal sent when the battery level has changed. |
batte ryTemperatureChanged |
signal
|
Signal sent when the battery temperature has changed. |
chargerStateChanged |
signal
|
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