8 extern APMInfo
*apminfo
;
15 if (!(apm
= fopen("/proc/apm", "r"))) {
16 fprintf(stderr
, "This system does not support APM\n");
24 void acquire_info(void)
30 int ac_line
, batt
, percent
, rtime
;
34 if (!(apm
= fopen("apm", "r")))
37 if (!(apm
= fopen("/proc/apm", "r")))
42 sscanf(buf
, "%*s %*s %*s %x %x %*s %d%% %d %s",
43 &ac_line
, &batt
, &percent
, &rtime
, min
);
45 eprint(0, "%02x %02x, %03d%%, %d", ac_line
, batt
, percent
, rtime
);
46 apminfo
->percentage
= percent
;
47 apminfo
->rtime
= rtime
;
50 case 0: /* on battery. calculate status. handle charging under AC */
53 apminfo
->power
= HIGH
;
59 apminfo
->power
= CRIT
;
63 /* check user-defined critical alarm */
64 if (apminfo
->percentage
<= apminfo
->crit_level
)
65 apminfo
->power
= CRIT
;
68 case 1: /* on AC power. Check if battery is being charged */
70 /* this is incase your battery is "charging" all the fucking time,
71 * even when it's actually done charging */
72 if ((batt
== 3) && (percent
!= 100))
76 apminfo
->power
= CHARGING
;
78 apminfo
->power
= POWER
;
81 /* treatment for GAY apm bioses that show wrong time
82 * remaining when AC is plugged in */
87 process_plugin_timer();
89 eprint(1, "current state: %s (%d)", state
[apminfo
->power
], apminfo
->power
);