summaryrefslogtreecommitdiff
path: root/statuses
diff options
context:
space:
mode:
authornorly <ny-git@enpas.org>2012-10-26 15:30:49 +0100
committernorly <ny-git@enpas.org>2012-10-26 15:30:49 +0100
commitea0de655211296526a44967e0a4010c064ac5158 (patch)
tree8d3c863e852172d665d409512d1153dcc5c79eba /statuses
parent0d20dbbfde089b69a3e925d049bb864816c14599 (diff)
Include fan.{c,h}
Diffstat (limited to 'statuses')
-rw-r--r--statuses/fan.c27
-rw-r--r--statuses/fan.h7
2 files changed, 34 insertions, 0 deletions
diff --git a/statuses/fan.c b/statuses/fan.c
new file mode 100644
index 0000000..2be5b28
--- /dev/null
+++ b/statuses/fan.c
@@ -0,0 +1,27 @@
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include "fan.h"
+
+void status_fan(char *title, char *sysfile)
+{
+ char stline[16];
+ int stfile;
+ 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);
+}
diff --git a/statuses/fan.h b/statuses/fan.h
new file mode 100644
index 0000000..dd5e494
--- /dev/null
+++ b/statuses/fan.h
@@ -0,0 +1,7 @@
+
+#ifndef __FAN_H__
+#define __FAN_H__
+
+void status_fan(char *title, char *sysfile);
+
+#endif