updated on Thu Jan 26 00:18:00 UTC 2012
[aur-mirror.git] / brightd / proposal.patch
blob31797a99ae3a5056bd994bf1017e525f2225a348
1 --- a/brightd.c 2008-10-19 23:10:21.000000000 +0200
2 +++ b/brightd.c 2011-11-09 22:01:24.394594536 +0100
3 @@ -172,7 +172,7 @@
6 /* We had to disable signal handler and alarm because of this: */
7 - usleep(200);
8 + usleep(10000);
10 signal(SIGALRM, signalHandlerAlarm);
11 alarm(saved);
12 @@ -184,15 +184,14 @@
13 int isOnAC() /*{{{*/
15 char line[255];
16 - FILE *ac = fopen("/proc/acpi/ac_adapter/AC/state", "r");
17 + FILE *ac = fopen("/sys/class/power_supply/AC/online", "r");
18 if(!ac) {
19 /* Ignore this */
20 return 0;
22 fgets(line, 255, ac);
23 fclose(ac);
25 - return strstr(line, "on-line") != NULL;
26 + return atoi(line);
27 } /*}}}*/
30 @@ -280,6 +279,7 @@
31 * Load default brightness class into b_class
33 void loadDefaultClass() /*{{{*/
36 struct dirent *dirEntry;
37 DIR *backlightDir = opendir("/sys/class/backlight");
38 @@ -289,7 +289,7 @@
39 if(!dirEntry) {
40 break;
42 - if(dirEntry->d_name[0] == '.') {
43 + if(dirEntry->d_name[0] == '.' || !strcmp(dirEntry->d_name,"intel_backlight")) {
44 continue;
46 strcpy(b_class, dirEntry->d_name);
47 @@ -325,7 +325,7 @@
49 if(isDark == 0) {
50 /* Check if fading is okay */
51 - if(isOnAC() && force < 2) {
52 + if(isOnAC() == 1 && force < 2) {
53 info("Would fade, but on AC");
54 alarm(waitSeconds);
55 return;