Xinqi Bao's Git
1 /* See LICENSE file for copyright and license details. */
8 #include <machine/apmvar.h>
10 #include "../../util.h"
13 battery_perc(const char *null
)
15 struct apm_power_info apm_info
;
18 fd
= open("/dev/apm", O_RDONLY
);
20 fprintf(stderr
, "open '/dev/apm': %s\n", strerror(errno
));
24 if (ioctl(fd
, APM_IOC_GETPOWER
, &apm_info
) < 0) {
25 fprintf(stderr
, "ioctl 'APM_IOC_GETPOWER': %s\n", strerror(errno
));
31 return bprintf("%d", apm_info
.battery_life
);