summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMoritz Augsburger <bug+debian@moritz.augsburger.name>2014-07-11 20:31:07 +0200
committerAndrej Shadura <andrewsh@debian.org>2018-09-05 14:48:36 +0200
commit617feb714824bc146d0ba2b935e29f51bc2f0303 (patch)
tree7b69552cec17fbbaa19782ce661b8b28fb70956c
parent665f5ab5e728e5c543b722887112bae031d1f3ec (diff)
Don’t use deprecated /proc/acpi for AC detection
brightd uses the old /proc/acpi/ac_adapter/AC/state to determine if the system is on AC. Instead, use /sys/class/power_supply/AC/online for this functionality. Bug-Debian: https://bugs.debian.org/754494 Gbp-Pq: Name 0002-Don-t-use-deprecated-proc-acpi-for-AC-detection.patch
-rw-r--r--brightd.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/brightd.c b/brightd.c
index 244dd60..e9958a6 100644
--- a/brightd.c
+++ b/brightd.c
@@ -183,16 +183,16 @@ void setBrightness(int level) { /*{{{*/
*/
int isOnAC() /*{{{*/
{
- char line[255];
- FILE *ac = fopen("/proc/acpi/ac_adapter/AC/state", "r");
+ int ac_state;
+ FILE *ac = fopen("/sys/class/power_supply/AC/online", "r");
if(!ac) {
/* Ignore this */
return 0;
}
- fgets(line, 255, ac);
+ ac_state = fgetc(ac);
fclose(ac);
- return strstr(line, "on-line") != NULL;
+ return ac_state;
} /*}}}*/
/*