diff --git a/doc/variables.xml b/doc/variables.xml
index cc62fd28..100790ec 100644
--- a/doc/variables.xml
+++ b/doc/variables.xml
@@ -1676,6 +1676,16 @@
Sensor 0 is on the CPU, 3 is on the GPU.
+
+
+
+
+
+
+ If running the IBM ACPI, displays the status of your
+ ThinkLight™. Value is either 'on', 'off' or 'unknown'.
+
+
diff --git a/src/core.cc b/src/core.cc
index 0ddeb36c..e39eefd9 100644
--- a/src/core.cc
+++ b/src/core.cc
@@ -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 */
diff --git a/src/ibm.cc b/src/ibm.cc
index d05191a1..8d9d1035 100644
--- a/src/ibm.cc
+++ b/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) {
diff --git a/src/ibm.h b/src/ibm.h
index 074307db..2b838bea 100644
--- a/src/ibm.h
+++ b/src/ibm.h
@@ -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);