summaryrefslogtreecommitdiff
path: root/src/status/fan.c
diff options
context:
space:
mode:
authornorly <ny-git@enpas.org>2013-02-15 01:19:41 +0000
committernorly <ny-git@enpas.org>2013-02-15 01:30:22 +0000
commit430ce2a8749eb90ca0f8cdf18f5b217128c43e79 (patch)
tree8c838780bda4c7ebf4f778ca307f01b2d39bdfbe /src/status/fan.c
parent2ddbfa53a31360e50565345a1ac08c0799c8243e (diff)
Better file structure and build system
Also fix some warnings
Diffstat (limited to 'src/status/fan.c')
-rw-r--r--src/status/fan.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/status/fan.c b/src/status/fan.c
new file mode 100644
index 0000000..0e7cfdf
--- /dev/null
+++ b/src/status/fan.c
@@ -0,0 +1,29 @@
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include "status/fan.h"
+#include "tools.h"
+
+
+void status_fan(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 > 5) {
+ printf(" ^fg(red)%sERROR ", title);
+ return;
+ }
+
+ fputs(" ^fg(#CCCCCC)", stdout);
+ fputs(title, stdout);
+ fwrite(stline, 1, stlen - 1, stdout);
+ fputs(" rpm ", stdout);
+}