From ea0de655211296526a44967e0a4010c064ac5158 Mon Sep 17 00:00:00 2001 From: norly Date: Fri, 26 Oct 2012 15:30:49 +0100 Subject: [PATCH] Include fan.{c,h} --- runstatus.sh | 2 +- statuses/fan.c | 27 +++++++++++++++++++++++++++ statuses/fan.h | 7 +++++++ sysstatus.c | 4 ++-- 4 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 statuses/fan.c create mode 100644 statuses/fan.h diff --git a/runstatus.sh b/runstatus.sh index a7681f7..c279115 100755 --- a/runstatus.sh +++ b/runstatus.sh @@ -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 index 0000000..2be5b28 --- /dev/null +++ b/statuses/fan.c @@ -0,0 +1,27 @@ +#include +#include +#include +#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 index 0000000..dd5e494 --- /dev/null +++ b/statuses/fan.h @@ -0,0 +1,7 @@ + +#ifndef __FAN_H__ +#define __FAN_H__ + +void status_fan(char *title, char *sysfile); + +#endif diff --git a/sysstatus.c b/sysstatus.c index ce6086b..9433da1 100644 --- a/sysstatus.c +++ b/sysstatus.c @@ -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); -- 2.30.2