From 7be768e78cf98b051616d4404d75d1fbb3f39890 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sat, 15 Sep 2007 19:06:48 -0400 Subject: [PATCH] auxstats: use acpi to find battery info on Linux (Andrey Mirtchovski) --- src/cmd/auxstats/Linux.c | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/src/cmd/auxstats/Linux.c b/src/cmd/auxstats/Linux.c index afd88407..2592bc4e 100644 --- a/src/cmd/auxstats/Linux.c +++ b/src/cmd/auxstats/Linux.c @@ -22,16 +22,37 @@ void (*statfn[])(int) = void xapm(int first) { - static int fd = -1; + static int fd = -1, fdb = -1; + int i, last = -1, curr = -1; if(first){ - fd = open("/proc/apm", OREAD); + fd = open("/proc/acpi/battery/BAT0/info", OREAD); + fdb = open("/proc/acpi/battery/BAT0/state", OREAD); return; } + if(fd == -1 || fdb == -1) + return; + readfile(fd); - tokens(0); - if(ntok >= 7 && atoi(tok[6]) != -1) - Bprint(&bout, "battery =%d 100\n", atoi(tok[6])); + for(i=0; i