84cfa9035f9d6cfc502c1a6c4047b5f8f4349f92
[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
17   // Read a valid value? Sometimes we get garbage from sysfs...
18   if (stlen > 5) {
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 }