]> git.sur5r.net Git - i3/i3status/commitdiff
i3status - Default to acpitz(4) instead of cpu(4) for OpenBSD temperature readings
authorJasper Lievisse Adriaanse <jasper@openbsd.org>
Wed, 10 Oct 2012 07:53:34 +0000 (09:53 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Tue, 16 Oct 2012 08:48:44 +0000 (10:48 +0200)
The acpitz(4) values are eventually used by the kernel to determine if the machine
is getting too hot.

include/i3status.h
src/print_cpu_temperature.c

index 23179369bc06a069a3e94d080cb3900287aa0822..93f979142abed204128fb4383149dc0adcd96ecc 100644 (file)
@@ -31,9 +31,11 @@ enum { O_DZEN2, O_XMOBAR, O_I3BAR, O_NONE } output_format;
  * Due to the fact there are various ways to obtain a temperature reading, THERMAL_ZONE will need
  * to be adjustable enough for those situations. As it can either be hw.sensors.cpu%d.temp0, or
  * hw.sensors.acpitz%d.temp0 or even something different entirely within hw.sensors.%s.temp0.
- * XXX: For now just check cpu%d.temp0. Adjust this later.
+ * XXX:
+ * Due to the fact the i3status API only allows to set the THERMAL_ZONE parameter to an integer,
+ * we can't make this fully configureable (yet?).
  */
-#define THERMAL_ZONE "cpu%d"
+#define THERMAL_ZONE "acpitz%d"
 
 #endif
 
index 8e7d7f9c4c23e0392c0e1940ec249e9b6dd24cfe..b1d122187e616064525340f9d9186c0369c72140 100644 (file)
@@ -88,18 +88,19 @@ void print_cpu_temperature_info(yajl_gen json_gen, char *buffer, int zone, const
                        goto error;
                }
                /*
-                * 'path' is actually the node within the full path (eg, cpu0).
+                * 'path' is actually the node within the full path (currently always acpitz0).
                 * XXX: Extend the API to allow a string instead of just an int for path, this would
-                * allow us to have a path of 'acpitz0' for example.
+                * allow us to build an arbitrary path.
                 */
                if (strncmp(sensordev.xname, path, strlen(path)) == 0) {
                        mib[3] = SENSOR_TEMP;
                        for (numt = 0; numt < sensordev.maxnumt[SENSOR_TEMP]; numt++) {
                                mib[4] = numt;
                                if (sysctl(mib, 5, &sensor, &slen, NULL, 0) == -1) {
-                                       if (errno != ENOENT)
+                                       if (errno != ENOENT) {
                                                warn("sysctl");
-                                       continue;
+                                               continue;
+                                       }
                                }
                                outwalk += sprintf(outwalk, "%.2f", (sensor.value - 273150000) / 1000000.0 );
                        }