Include fan.{c,h}
[sysstatus.git] / statuses / fan.c
1 #include <stdio.h>
2 #include <fcntl.h>
3 #include <unistd.h>
4 #include "fan.h"
5
6 void status_fan(char *title, char *sysfile)
7 {
8         char stline[16];
9         int stfile;
10         ssize_t stlen;
11
12         stlen = fileRead(stline, sizeof(stline), sysfile);
13         if (stlen <= 0)
14                 return;
15
16         // Read a valid value? Sometimes we get garbage from sysfs...
17         if (stlen > 5)
18         {
19                 printf(" ^fg(red)%sERROR ", title);
20                 return;
21         }
22
23         fputs(" ^fg(#CCCCCC)", stdout);
24         fputs(title, stdout);
25         fwrite(stline, 1, stlen - 1, stdout);
26         fputs(" rpm ", stdout);
27 }