From 1c9db76c01403be056f2ebe9bd0e6ce4fd759020 Mon Sep 17 00:00:00 2001 From: Dustin Kirkland Date: Thu, 27 Jan 2011 09:55:33 -0600 Subject: [PATCH] usr/lib/byobu/fan_speed: add support for /proc/i8k for some other systems' fan speeds (e.g. Dell Inspiron), LP: #700204 --- debian/changelog | 2 ++ usr/lib/byobu/fan_speed | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 8ebe1476..417a4b31 100644 --- a/debian/changelog +++ b/debian/changelog @@ -15,6 +15,8 @@ byobu (3.26) unreleased; urgency=low [ Dustin Kirkland + swalker ] * usr/lib/byobu/wifi_quality: avoid potential divide by zero error + * usr/lib/byobu/fan_speed: add support for /proc/i8k for some other + systems' fan speeds (e.g. Dell Inspiron), LP: #700204 -- Dustin Kirkland Sun, 23 Jan 2011 16:28:45 -0600 diff --git a/usr/lib/byobu/fan_speed b/usr/lib/byobu/fan_speed index cac17357..195df432 100755 --- a/usr/lib/byobu/fan_speed +++ b/usr/lib/byobu/fan_speed @@ -23,13 +23,16 @@ color 2>/dev/null || color() { true; } DIR="/sys/class/hwmon" if [ "$1" = "--detail" ]; then - for i in $DIR/*; do + for i in $DIR/* /proc/i8k; do echo "$i:" cat "$DIR/$i"/* 2>/dev/null done exit 0 fi +# Let's check a few different probes for fan speed + +# This seems to cover most of them: for i in $(find $DIR/*/*/ -type f -name "fan1_input"); do speed=$(cat "$i") if [ "$speed" -gt 0 ]; then @@ -37,3 +40,17 @@ for i in $(find $DIR/*/*/ -type f -name "fan1_input"); do exit 0 fi done + +# But others (e.g. Dell Inspirons) seem to be here: +if [ -r /proc/i8k ]; then + for speed in $(awk '{ print $7, $8 }' /proc/i8k); do + if [ "$speed" -gt 0 ]; then + # I8K_FAN_MULT defaults to 30 (buggy BIOS workaround?), + # use `modprobe i8k fan_mult=1` to disable if unneeded, + # resulting in nonsensical speeds + [ "$speed" -gt 10000 ] && speed=$((${speed} / 30)) + printf "$(color bold1)%s$(color -)$(color none)%s$(color -) " "$speed" "rpm" + exit 0 + fi + done +fi