openbsd-ports/x11/xmobar/files/apm.c
kili 671ec9137c Update to to version 0.11.1.
Add battery monitor support for OpenBSD.

From maintainer Jona Joachim.
2010-07-17 14:55:21 +00:00

28 lines
362 B
C

#include "apm.h"
int get_power_info(struct apm_power_info *power_info)
{
int fd, ret;
fd = open(APMDEV, O_RDONLY, 0);
if(fd == -1)
{
warn("Could not open " APMDEV);
goto ERR;
}
ret = ioctl(fd, APM_IOC_GETPOWER, power_info);
if(ret == -1)
{
warn("Could not ioctl " APMDEV);
goto ERR;
}
close(fd);
return 0;
ERR:
close(fd);
return -1;
}