Change named colors to hex values
[sysstatus.git] / src / status / fan.c
1 #include <stdio.h>
2 #include <fcntl.h>
3 #include <unistd.h>
4
5 #include "common.h"
6 #include "tools.h"
7
8
9 void status_fan(GlobalData *g, char *title, char *sysfile)
10 {
11   StatusItem s;
12   char text[16] = { 0 };
13
14   char stline[16];
15   ssize_t stlen;
16
17
18   statusitem_init(&s);
19   s.text = text;
20
21   stlen = fileRead(stline, sizeof(stline), sysfile);
22   if (stlen <= 0) {
23     return;
24   }
25
26   // Read a valid value? Sometimes we get garbage from sysfs...
27   if (stlen > 5) {
28     s.color = "#FF0000";  // red
29     snprintf(text, sizeof(text), "%sERROR", title);
30   } else {
31     stline[stlen - 1] = '\0';
32
33     s.color = "#CCCCCC";
34     snprintf(text, sizeof(text), "%s%s rpm", title, stline);
35   }
36
37   line_append_item(g, &s);
38 }