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.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/status/fan.c b/src/status/fan.c
index 0e7cfdf..6b26678 100644
--- a/src/status/fan.c
+++ b/src/status/fan.c
@@ -2,15 +2,22 @@
#include <fcntl.h>
#include <unistd.h>
-#include "status/fan.h"
+#include "common.h"
#include "tools.h"
-void status_fan(char *title, char *sysfile)
+void status_fan(GlobalData *g, char *title, char *sysfile)
{
+ StatusItem s;
+ char text[16] = { 0 };
+
char stline[16];
ssize_t stlen;
+
+ statusitem_init(&s);
+ s.text = text;
+
stlen = fileRead(stline, sizeof(stline), sysfile);
if (stlen <= 0) {
return;
@@ -18,12 +25,14 @@ void status_fan(char *title, char *sysfile)
// Read a valid value? Sometimes we get garbage from sysfs...
if (stlen > 5) {
- printf(" ^fg(red)%sERROR ", title);
- return;
+ s.color = "red";
+ snprintf(text, sizeof(text), "%sERROR", title);
+ } else {
+ stline[stlen - 1] = '\0';
+
+ s.color = "#CCCCCC";
+ snprintf(text, sizeof(text), "%s%s rpm", title, stline);
}
- fputs(" ^fg(#CCCCCC)", stdout);
- fputs(title, stdout);
- fwrite(stline, 1, stlen - 1, stdout);
- fputs(" rpm ", stdout);
+ line_append_item(g, &s);
}