Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ##########################################################################
- #
- # Script to control (AMD/ATI) fanspeeds depending on the GPUs temperature
- #
- # Copyright 2011 Markus Niemann (markus@chanoa.de)
- #
- ##########################################################################
- # This program is free software: you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation, either version 3 of the License, or
- # (at your option) any later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
- ##########################################################################
- #
- # Usage: [screen -dmS fan#] autofan.sh {DeviceID}
- #
- ##########################################################################
- DEVICE=$1
- export DISPLAY=:0.${DEVICE}
- # initial fanspeed
- FANSPEED=75
- # maximum temperature, toggles 100% fanspeed
- MAXTEMP=80
- # middle temperature, exceeding this temperature will speed up fan
- MIDTEMP=78
- # minimum temperature, deceeding this temperature will speed down fan
- MINTEMP=76
- # minimum fanspeed
- MINSPEED=60
- # percentage fanspeed steps this script will toggle
- FANSTEPS=2
- # time interval in seconds this script will check temperature
- SLEEP=20
- if [ $# -ne 1 ]
- then
- echo "Usage: `basename $0` {DeviceID}"
- exit $E_BADARGS
- fi
- function getTemp {
- currenttemp=$(sudo aticonfig --odgt --adapter=$DEVICE | grep C)
- currenttemp=${currenttemp##*- }
- echo ${currenttemp%%.*}
- }
- function setFanSpeed {
- case $1 in
- up)
- if [ $FANSPEED -lt 100 ]
- then
- FANSPEED=$((FANSPEED+FANSTEPS))
- echo up to $FANSPEED %
- sudo aticonfig --pplib-cmd "set fanspeed 0 $FANSPEED" > /dev/null
- else
- echo Fanspeed already 100%!
- fi
- ;;
- down)
- if [ $FANSPEED -gt $MINSPEED ]
- then
- FANSPEED=$((FANSPEED-FANSTEPS))
- echo down to $FANSPEED %
- sudo aticonfig --pplib-cmd "set fanspeed 0 $FANSPEED" > /dev/null
- else
- echo Fanspeed already low enough!
- fi
- ;;
- *)
- FANSPEED=$1
- echo up to $FANSPEED %
- sudo aticonfig --pplib-cmd "set fanspeed 0 $FANSPEED" > /dev/null
- ;;
- esac
- }
- setFanSpeed $FANSPEED
- while [ 0 == 0 ]
- do
- sleep $SLEEP
- TEMP=`getTemp`
- echo Temp is $TEMP
- if [[ $TEMP -ge $MAXTEMP ]]
- then
- setFanSpeed 100
- else
- if [[ $TEMP -ge $MIDTEMP ]]
- then
- setFanSpeed up
- else
- if [[ $TEMP -le $MINTEMP ]]
- then
- setFanSpeed down
- fi
- fi
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement