mirror of
https://github.com/xzeldon/htop.git
synced 2025-07-12 12:14:36 +03:00
Update battery API to use NAN on error
This commit is contained in:
@ -7,13 +7,14 @@ in the source distribution for its full text.
|
||||
*/
|
||||
|
||||
#include "BatteryMeter.h"
|
||||
#include <math.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;
|
||||
*level = NAN;
|
||||
else
|
||||
*level = life;
|
||||
|
||||
|
Reference in New Issue
Block a user