From 7d827b5cca185b411be3ac9b71834958f4737bdf Mon Sep 17 00:00:00 2001 From: Zach Scott Date: Thu, 19 Sep 2019 17:08:36 +0000 Subject: auxstats: replace /proc ACPI calls with /sys ones (#245) According to , use of `/proc/acpi` to get battery usage is deprecated. This commit replaces the two files from this API with the single file `/sys/class/power_supply/BAT0/capacity`, simultaneously removing the need to calculate battery percentage. --- src/cmd/auxstats/Linux.c | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) (limited to 'src/cmd/auxstats/Linux.c') diff --git a/src/cmd/auxstats/Linux.c b/src/cmd/auxstats/Linux.c index 09ca18f3..64c86a26 100644 --- a/src/cmd/auxstats/Linux.c +++ b/src/cmd/auxstats/Linux.c @@ -26,36 +26,22 @@ void (*statfn[])(int) = void xapm(int first) { - static int fd = -1, fdb = -1; - int i, last = -1, curr = -1; + static int fd = -1; + int curr = -1; if(first){ - fd = open("/proc/acpi/battery/BAT0/info", OREAD); - fdb = open("/proc/acpi/battery/BAT0/state", OREAD); + fd = open("/sys/class/power_supply/BAT0/capacity", OREAD); return; } - if(fd == -1 || fdb == -1) + if(fd == -1) return; readfile(fd); - for(i=0; i