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>2019-12-11 14:12:49 +0100
commit279585c14f29d823a64102cb53f6a7220766559c (patch)
treea73a513eb227243c6e1f4bd54700b781d3ac94d1
parent8e5a6072af2fe3474446fcbcdede36cf15300545 (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..3384c7a 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 != '0';
} /*}}}*/
/*