make it possible to get temperature readings from devices other than acpitz.

use the 'path' option in your configuration's cpu_temperature block to e.g. cpu0.
This commit is contained in:
jasper 2012-10-09 16:02:07 +00:00
parent 4c40122e40
commit dd671692ea
4 changed files with 51 additions and 34 deletions

View File

@ -1,11 +1,11 @@
# $OpenBSD: Makefile,v 1.22 2012/10/09 13:19:48 jasper Exp $
# $OpenBSD: Makefile,v 1.23 2012/10/09 16:02:07 jasper Exp $
ONLY_FOR_ARCHS= ${APM_ARCHS}
COMMENT= generate a statusbar for use with i3/xmobar/dzen2
DISTNAME= i3status-2.6
REVISION= 13
REVISION= 14
CATEGORIES= x11 sysutils
HOMEPAGE= http://i3wm.org/i3status/

View File

@ -1,10 +1,10 @@
$OpenBSD: patch-i3status_conf,v 1.8 2012/10/09 13:19:48 jasper Exp $
$OpenBSD: patch-i3status_conf,v 1.9 2012/10/09 16:02:07 jasper Exp $
Adjust config file to be reasonably useful on OpenBSD out of the box.
--- i3status.conf.orig Wed Oct 3 13:44:44 2012
+++ i3status.conf Tue Oct 9 17:12:12 2012
@@ -1,41 +1,37 @@
+++ i3status.conf Tue Oct 9 19:44:34 2012
@@ -1,41 +1,43 @@
general {
+ output_format = "i3bar"
colors = true
@ -22,18 +22,24 @@ Adjust config file to be reasonably useful on OpenBSD out of the box.
order += "battery 0"
order += "load"
order += "time"
+order += "cpu_temperature acpitz0" # device is not configureable...
+order += "cpu_temperature cpu0"
+order += "cpu_temperature acpitz0"
+order += "volume master"
-wireless wlan0 {
- format_up = "W: (%quality at %essid) %ip"
- format_down = "W: down"
+cpu_temperature acpitz0 {
+ format = "TZ: %degrees C"
+cpu_temperature cpu0 {
+ format = "C: %degrees C"
+ path = "cpu0"
}
-ethernet eth0 {
- # if you use %speed, i3status requires root privileges
+cpu_temperature acpitz0 {
+ format = "TZ: %degrees C"
+}
+
+#wireless iwn0 {
+# format_up = "W: (%signal at %essid) %ip"
+# format_down = "W: down"
@ -60,7 +66,7 @@ Adjust config file to be reasonably useful on OpenBSD out of the box.
time {
format = "%Y-%m-%d %H:%M:%S"
}
@@ -46,4 +42,8 @@ load {
@@ -46,4 +48,8 @@ load {
disk "/" {
format = "%free (or: %percentage_used used, %percentage_used_of_avail used of avail, %percentage_free free, %percentage_avail avail)"

View File

@ -1,22 +1,28 @@
$OpenBSD: patch-include_i3status_h,v 1.5 2012/10/09 13:19:48 jasper Exp $
$OpenBSD: patch-include_i3status_h,v 1.6 2012/10/09 16:02:07 jasper Exp $
Default to acpitz(4) for temperature readings, instead of cpu(4).
The acpitz(4) values are eventually used by the kernel to determine if the machine
is getting too hot.
--- include/i3status.h.orig Tue Oct 9 17:10:15 2012
+++ include/i3status.h Tue Oct 9 17:10:22 2012
@@ -31,9 +31,11 @@ enum { O_DZEN2, O_XMOBAR, O_I3BAR, O_NONE } output_for
* 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"
Other devices can be used by setting 'path' in the config file to the sysctl(3)
device node.
--- include/i3status.h.orig Wed Oct 3 13:44:44 2012
+++ include/i3status.h Tue Oct 9 19:39:37 2012
@@ -27,14 +27,8 @@ enum { O_DZEN2, O_XMOBAR, O_I3BAR, O_NONE } output_for
#define BATT_STATE "hw.acpi.battery.state"
#elif defined(__OpenBSD__)
-/*
- * 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.
- */
-#define THERMAL_ZONE "cpu%d"
-
+/* Default to acpitz(4) if no path is set. */
+#define THERMAL_ZONE "acpitz%d"
#endif
#if defined(__FreeBSD_kernel__) && defined(__GLIBC__)

View File

@ -1,24 +1,29 @@
$OpenBSD: patch-src_print_cpu_temperature_c,v 1.3 2012/10/09 13:19:48 jasper Exp $
$OpenBSD: patch-src_print_cpu_temperature_c,v 1.4 2012/10/09 16:02:07 jasper Exp $
Default to acpitz(4) for temperature readings, instead of cpu(4).
The acpitz(4) values are eventually used by the kernel to determine if the machine
is getting too hot.
--- src/print_cpu_temperature.c.orig Tue Oct 9 17:09:57 2012
+++ src/print_cpu_temperature.c Tue Oct 9 17:10:07 2012
@@ -88,18 +88,19 @@ void print_cpu_temperature_info(yajl_gen json_gen, cha
Other devices can be used by setting 'path' in the config file to the sysctl(3)
device node.
--- src/print_cpu_temperature.c.orig Wed Oct 3 13:44:44 2012
+++ src/print_cpu_temperature.c Tue Oct 9 19:41:02 2012
@@ -87,19 +87,17 @@ void print_cpu_temperature_info(yajl_gen json_gen, cha
break;
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
- * 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.
*/
- */
+ /* 'path' is the node within the full path (defaults to acpitz0). */
if (strncmp(sensordev.xname, path, strlen(path)) == 0) {
mib[3] = SENSOR_TEMP;
for (numt = 0; numt < sensordev.maxnumt[SENSOR_TEMP]; numt++) {
- for (numt = 0; numt < sensordev.maxnumt[SENSOR_TEMP]; numt++) {
+ /* Limit to temo0, but should retrieve from a full path... */
+ for (numt = 0; numt < 1 /*sensordev.maxnumt[SENSOR_TEMP]*/; numt++) {
mib[4] = numt;
if (sysctl(mib, 5, &sensor, &slen, NULL, 0) == -1) {
- if (errno != ENOENT)
@ -30,7 +35,7 @@ is getting too hot.
}
outwalk += sprintf(outwalk, "%.2f", (sensor.value - 273150000) / 1000000.0 );
}
@@ -109,9 +110,9 @@ void print_cpu_temperature_info(yajl_gen json_gen, cha
@@ -109,9 +107,9 @@ void print_cpu_temperature_info(yajl_gen json_gen, cha
walk += strlen("degrees");
}
}