[wiki] [sites] A temperature helper function for dwmstatus. || Christoph Lohmann
changeset: 964:0c1b93248137
tag: tip
user: Christoph Lohmann <20h_AT_r-36.net>
date: Sat Jul 28 11:05:59 2012 +0200
files: dwm.suckless.org/dwmstatus/dwmstatus-temperature.c dwm.suckless.org/dwmstatus/index.md
description:
A temperature helper function for dwmstatus.
diff -r 2de298e9003c -r 0c1b93248137 dwm.suckless.org/dwmstatus/dwmstatus-temperature.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dwm.suckless.org/dwmstatus/dwmstatus-temperature.c Sat Jul 28 11:05:59 2012 +0200
_AT_@ -0,0 +1,15 @@
+/*
+ * gettemperature("/sys/class/hwmon/hwmon0/device", "temp1_input");
+ */
+
+char *
+gettemperature(char *base, char *sensor)
+{
+ char *co;
+
+ co = readfile(base, sensor);
+ if (co == NULL)
+ return smprintf("");
+ return smprintf("%02.0f°C", atof(co) / 1000);
+}
+
diff -r 2de298e9003c -r 0c1b93248137 dwm.suckless.org/dwmstatus/index.md
--- a/dwm.suckless.org/dwmstatus/index.md Sun Jul 22 14:22:19 2012 +0200
+++ b/dwm.suckless.org/dwmstatus/index.md Sat Jul 28 11:05:59 2012 +0200
_AT_@ -29,4 +29,5 @@
add them here as file or as code example.
* [Support for ACPI battery status Linux](new-acpi-battery.c)
+* [Reading out a temperature from /sys](dwmstatus-temperature.c)
Received on Sat Jul 28 2012 - 11:06:04 CEST
This archive was generated by hypermail 2.3.0
: Thu Sep 13 2012 - 19:32:30 CEST