summaryrefslogtreecommitdiff
path: root/src/status/temp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/status/temp.c')
-rw-r--r--src/status/temp.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/status/temp.c b/src/status/temp.c
new file mode 100644
index 0000000..e6763d0
--- /dev/null
+++ b/src/status/temp.c
@@ -0,0 +1,36 @@
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include "status/temp.h"
+#include "tools.h"
+
+
+void status_temp(char *title, char *sysfile)
+{
+ char stline[16];
+ ssize_t stlen;
+
+ stlen = fileRead(stline, sizeof(stline), sysfile);
+ if (stlen <= 0) {
+ return;
+ }
+
+ /*
+ * Read a valid value?
+ * Sometimes we get garbage from sysfs...
+ */
+ if (stlen < 6 || stlen > 7) {
+ printf(" ^fg(red)%sERROR ", title);
+ return;
+ }
+
+ fputs(" ^fg(#FF33FF)", stdout);
+ fputs(title, stdout);
+ fwrite(stline, 1, stlen - 4, stdout);
+ /*
+ fputs(".", stdout);
+ fwrite(&stline[stlen - 3], 1, 1, stdout);
+ */
+ fputs("°C ", stdout);
+}