From d6dced050369e62bfd4909cad520cd4918739b50 Mon Sep 17 00:00:00 2001 From: xloem <0xloem@gmail.com> Date: Sat, 29 Apr 2023 17:25:21 -0400 Subject: [PATCH] fancontrol: Executable commands as temp sensors. --- prog/pwm/fancontrol | 22 ++++++++++++++++++---- prog/pwm/fancontrol.8 | 4 +++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/prog/pwm/fancontrol b/prog/pwm/fancontrol index 886a7367..0e1e9d79 100755 --- a/prog/pwm/fancontrol +++ b/prog/pwm/fancontrol @@ -297,10 +297,19 @@ function CheckFiles while (( $fcvcount < ${#AFCTEMP[@]} )) # go through all temp inputs do tsen=${AFCTEMP[$fcvcount]} - if [ ! -r $tsen ] + if [ ${tsen::1} == "!" ] then - echo "Error: file $tsen doesn't exist or isn't readable" >&2 - outdated=1 + if ! [ -x ${tsen:1} ] + then + echo "Error: file ${tsen:1} doesn't exist or isn't executable" >&2 + outdated=1 + fi + else + if ! [ -r $tsen ] + then + echo "Error: file $tsen doesn't exist or isn't readable" >&2 + outdated=1 + fi fi let fcvcount=$fcvcount+1 done @@ -541,7 +550,12 @@ function UpdateFanSpeeds maxpwm=${AFCMAXPWM[$fcvcount]} avg=${AFCAVERAGE[$fcvcount]} - read tlastval < ${tsens} + if [ ${tsens::1} == "!" ] + then + tlastval="$(${tsens:1})" + else + read tlastval < ${tsens} + fi if [ $? -ne 0 ] then echo "Error reading temperature from $DIR/$tsens" diff --git a/prog/pwm/fancontrol.8 b/prog/pwm/fancontrol.8 index 43325903..48190bc2 100644 --- a/prog/pwm/fancontrol.8 +++ b/prog/pwm/fancontrol.8 @@ -49,7 +49,9 @@ the configuration file is still up-to-date. .B FCTEMPS Maps PWM outputs to temperature sensors so \fBfancontrol\fP knows which temperature sensors should be used for calculation of new values for -the corresponding PWM outputs. +the corresponding PWM outputs. A prefix of ! can be used to execute a +command as a temperature sensor. + .TP .B FCFANS Records the association between a PWM output and a fan input.