aboutsummaryrefslogtreecommitdiff
path: root/libLumina/LuminaOS-DragonFly.cpp
diff options
context:
space:
mode:
authorMichael Neumann <mneumann@ntecs.de>2015-08-16 16:35:39 +0200
committerMichael Neumann <mneumann@ntecs.de>2015-08-16 16:35:39 +0200
commit0b4fa586baa82d27021f2e7a561d98ac42e06ba2 (patch)
tree09475baf584c34316db9d97625499b260bc0bed0 /libLumina/LuminaOS-DragonFly.cpp
parentDragonFly does not have graphical mixer (diff)
downloadlumina-0b4fa586baa82d27021f2e7a561d98ac42e06ba2.tar.gz
lumina-0b4fa586baa82d27021f2e7a561d98ac42e06ba2.tar.bz2
lumina-0b4fa586baa82d27021f2e7a561d98ac42e06ba2.zip
Implement Battery hooks for DragonFly
Diffstat (limited to 'libLumina/LuminaOS-DragonFly.cpp')
-rw-r--r--libLumina/LuminaOS-DragonFly.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/libLumina/LuminaOS-DragonFly.cpp b/libLumina/LuminaOS-DragonFly.cpp
index 8c406713..73815ea0 100644
--- a/libLumina/LuminaOS-DragonFly.cpp
+++ b/libLumina/LuminaOS-DragonFly.cpp
@@ -187,25 +187,30 @@ void LOS::systemSuspend(){
//Battery Availability
bool LOS::hasBattery(){
- int val = LUtils::getCmdOutput("apm -l").join("").toInt();
- return (val >= 0 && val <= 100);
+ int val = LUtils::getCmdOutput("sysctl -n hw.acpi.battery.units").join("").toInt();
+ return (val >= 1);
}
//Battery Charge Level
int LOS::batteryCharge(){ //Returns: percent charge (0-100), anything outside that range is counted as an error
- int charge = LUtils::getCmdOutput("apm -l").join("").toInt();
+ int charge = LUtils::getCmdOutput("sysctl -n hw.acpi.battery.life").join("").toInt();
if(charge > 100){ charge = -1; } //invalid charge
return charge;
}
//Battery Charging State
bool LOS::batteryIsCharging(){
- return (LUtils::getCmdOutput("apm -a").join("").simplified() == "1");
+ return (LUtils::getCmdOutput("sysctl -n hw.acpi.battery.state").join("").simplified() == "2");
}
//Battery Time Remaining
int LOS::batterySecondsLeft(){ //Returns: estimated number of seconds remaining
- return LUtils::getCmdOutput("apm -t").join("").toInt();
+ int time = LUtils::getCmdOutput("sysctl -n hw.acpi.battery.time").join("").toInt();
+ if (time > 0) {
+ // time is in minutes
+ time *= 60;
+ }
+ return time;
}
//File Checksums
bgstack15