-
-
Notifications
You must be signed in to change notification settings - Fork 624
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from eskerda/eskerda-thinklight
add support for $ibm_thinklight
- Loading branch information
Showing
4 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -261,6 +261,50 @@ void get_ibm_acpi_brightness(struct text_object *obj, char *p, int p_max_size) | |
snprintf(p, p_max_size, "%d", brightness); | ||
} | ||
|
||
/* get ThinkLight status on IBM/Lenovo laptops running the ibm acpi. | ||
* /proc/acpi/ibm/light looks like this (2 lines): | ||
status: off | ||
commands: on, off | ||
* http://ibm-acpi.sourceforge.net/README reports that it's also possible to | ||
* get "unknown" for a few models that do not make the status available. | ||
* Lluis Esquerda ([email protected]) */ | ||
|
||
void get_ibm_acpi_thinklight(struct text_object *obj, char *p, int p_max_size) | ||
{ | ||
FILE *fp; | ||
char thinklight[8]; | ||
char filename[128]; | ||
|
||
(void)obj; | ||
|
||
if (!p || p_max_size <= 0) { | ||
return; | ||
} | ||
|
||
snprintf(filename, 127, "%s/light", IBM_ACPI_DIR); | ||
|
||
fp = fopen(filename, "r"); | ||
if (fp != NULL) { | ||
while (!feof(fp)) { | ||
char line[256]; | ||
|
||
if (fgets(line, 255, fp) == NULL) { | ||
break; | ||
} | ||
if (sscanf(line, "status: %s", thinklight)) { | ||
break; | ||
} | ||
} | ||
} else { | ||
CRIT_ERR(NULL, NULL, "can't open '%s': %s\nYou are not using the IBM " | ||
"ACPI. Remove ibm* from your " PACKAGE_NAME" config file.", | ||
filename, strerror(errno)); | ||
} | ||
|
||
fclose(fp); | ||
snprintf(p, p_max_size, "%s", thinklight); | ||
} | ||
|
||
void parse_ibm_temps_arg(struct text_object *obj, const char *arg) | ||
{ | ||
if (!isdigit(arg[0]) || strlen(arg) > 1 || atoi(&arg[0]) >= 8) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters