You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
691 B
26 lines
691 B
/* |
|
htop - dragonflybsd/Battery.c |
|
(C) 2015 Hisham H. Muhammad |
|
(C) 2017 Diederik de Groot |
|
Released under the GNU GPL, see the COPYING file |
|
in the source distribution for its full text. |
|
*/ |
|
|
|
#include "BatteryMeter.h" |
|
#include <sys/sysctl.h> |
|
|
|
void Battery_getData(double* level, ACPresence* isOnAC) { |
|
int life; |
|
size_t life_len = sizeof(life); |
|
if (sysctlbyname("hw.acpi.battery.life", &life, &life_len, NULL, 0) == -1) |
|
*level = -1; |
|
else |
|
*level = life; |
|
|
|
int acline; |
|
size_t acline_len = sizeof(acline); |
|
if (sysctlbyname("hw.acpi.acline", &acline, &acline_len, NULL, 0) == -1) |
|
*isOnAC = AC_ERROR; |
|
else |
|
*isOnAC = acline == 0 ? AC_ABSENT : AC_PRESENT; |
|
}
|
|
|