Include fan.{c,h}
authornorly <ny-git@enpas.org>
Fri, 26 Oct 2012 14:30:49 +0000 (15:30 +0100)
committernorly <ny-git@enpas.org>
Fri, 26 Oct 2012 14:30:49 +0000 (15:30 +0100)
runstatus.sh
statuses/fan.c [new file with mode: 0644]
statuses/fan.h [new file with mode: 0644]
sysstatus.c

index a7681f77439148830bc5a2aeeb443e415e1dd9a1..c279115042fa14eb4035f01130c8d4c70f6b450e 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-MAXRESX=1680
+MAXRESX=1920
 
 RES=$(xrandr --prop | sed "s/Screen 0:[^,]*, current \(.*\) x \(.*\),.*/\1,\2/g;te;d;:e")
 RESX=${RES%%,*}
diff --git a/statuses/fan.c b/statuses/fan.c
new file mode 100644 (file)
index 0000000..2be5b28
--- /dev/null
@@ -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 (file)
index 0000000..dd5e494
--- /dev/null
@@ -0,0 +1,7 @@
+
+#ifndef __FAN_H__
+#define __FAN_H__
+
+void status_fan(char *title, char *sysfile);
+
+#endif
index ce6086b4d2a6fe37aba376a8bf45b54c3a880052..9433da101a42957cea812ad11b220f2e8e892190 100644 (file)
@@ -33,9 +33,9 @@ void updatestatus()
 
        //status_temp("GPU: ", "/sys/class/hwmon/hwmon0/device/temp4_input");
        //status_temp("CPU: ", "/sys/class/hwmon/hwmon0/device/temp2_input");
-       status_temp("CPU: ", "/sys/class/hwmon/hwmon1/device/temp1_input");
+       status_temp("CPU: ", "/sys/devices/platform/coretemp.0/temp1_input");
 
-       status_fan("Fan: ", "/sys/class/hwmon/hwmon2/device/fan1_input");
+       status_fan("Fan: ", "/sys/devices/platform/thinkpad_hwmon/fan1_input");
 
        status_volume_alsa("default", "Master", 0);