simple cli for tuxedo laptop N150ZU

autofan.sh 369B

12345678910111213141516171819202122
  1. #!/bin/bash
  2. # low = cool but loud, high = silent but hot
  3. MAGIC=36
  4. FN=/usr/local/bin/fancontrol
  5. AVG=1
  6. # main
  7. while sleep 1
  8. do
  9. TEMP=$($FN -r)
  10. DUTY=$(( ($TEMP - $MAGIC) * 8 ))
  11. DUTY=$(( $DUTY > 255 ? 255 : $DUTY ))
  12. DUTY=$(( $DUTY < 1 ? 1 : $DUTY ))
  13. AVG=$(echo "scale=2; ($DUTY+(2*$AVG))/3" | bc -l)
  14. echo $($FN $(printf %.$2f $AVG)) target=$DUTY temp=$TEMP
  15. done