summaryrefslogtreecommitdiff
path: root/src/status/fan.c
diff options
context:
space:
mode:
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);
+}