mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-26 12:27:52 +00:00
add support for $ibm_thinklight
Some IBM/Lenovo models come with a light on the top edge of the display to illuminate the keyboard. This either reports 'on', 'off' or 'unknown'.
This commit is contained in:
parent
b5e17a4c50
commit
68263d4556
@ -1676,6 +1676,16 @@
|
||||
Sensor 0 is on the CPU, 3 is on the GPU.
|
||||
<para /></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command>
|
||||
<option>ibm_thinklight</option>
|
||||
</command>
|
||||
</term>
|
||||
<listitem>If running the IBM ACPI, displays the status of your
|
||||
ThinkLight™. Value is either 'on', 'off' or 'unknown'.
|
||||
<para /></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command>
|
||||
|
@ -509,6 +509,8 @@ struct text_object *construct_text_object(char *s, const char *arg,
|
||||
obj->callbacks.print = &get_ibm_acpi_volume;
|
||||
END OBJ(ibm_brightness, 0)
|
||||
obj->callbacks.print = &get_ibm_acpi_brightness;
|
||||
END OBJ(ibm_thinklight, 0)
|
||||
obj->callbacks.print = &get_ibm_acpi_thinklight;
|
||||
#endif
|
||||
/* information from sony_laptop kernel module
|
||||
* /sys/devices/platform/sony-laptop */
|
||||
|
44
src/ibm.cc
44
src/ibm.cc
@ -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 (eskerda@gmail.com) */
|
||||
|
||||
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) {
|
||||
|
@ -30,6 +30,7 @@ void get_ibm_acpi_fan(struct text_object *, char *, int);
|
||||
int get_ibm_acpi_temps(void);
|
||||
void get_ibm_acpi_volume(struct text_object *, char *, int);
|
||||
void get_ibm_acpi_brightness(struct text_object *, char *, int);
|
||||
void get_ibm_acpi_thinklight(struct text_object *, char *, int);
|
||||
|
||||
void parse_ibm_temps_arg(struct text_object *, const char *);
|
||||
void print_ibm_temps(struct text_object *, char *, int);
|
||||
|
Loading…
Reference in New Issue
Block a user