|
|
|
@ -2,10 +2,10 @@
|
|
|
|
|
|
|
|
|
|
# Usage: temp_throttle.sh max_temp
|
|
|
|
|
# USE CELSIUS TEMPERATURES.
|
|
|
|
|
# version 2.20
|
|
|
|
|
# version 2.21
|
|
|
|
|
|
|
|
|
|
cat << EOF
|
|
|
|
|
Author: Sepero 2013 (sepero 111 @ gmx . com)
|
|
|
|
|
Author: Sepero 2016 (sepero 111 @ gmx . com)
|
|
|
|
|
URL: http://github.com/Sepero/temp-throttle/
|
|
|
|
|
|
|
|
|
|
EOF
|
|
|
|
@ -56,7 +56,7 @@ FREQ_MAX="/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq"
|
|
|
|
|
# Store available cpu frequencies in a space separated string FREQ_LIST.
|
|
|
|
|
if [ -f $FREQ_FILE ]; then
|
|
|
|
|
# If $FREQ_FILE exists, get frequencies from it.
|
|
|
|
|
FREQ_LIST=$(cat $FREQ_FILE) || err_exit "Could not read available cpu frequencies from file $FREQ_FILE"
|
|
|
|
|
FREQ_LIST=$(cat $FREQ_FILE | xargs -n1 | sort -g -r | xargs) || err_exit "Could not read available cpu frequencies from file $FREQ_FILE"
|
|
|
|
|
elif [ -f $FREQ_MIN -a -f $FREQ_MAX ]; then
|
|
|
|
|
# Else if $FREQ_MIN and $FREQ_MAX exist, generate a list of frequencies between them.
|
|
|
|
|
FREQ_LIST=$(seq $(cat $FREQ_MAX) -100000 $(cat $FREQ_MIN)) || err_exit "Could not compute available cpu frequencies"
|
|
|
|
@ -132,21 +132,24 @@ unthrottle () {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get_temp () {
|
|
|
|
|
# Get the system temperature.
|
|
|
|
|
# Get the system temperature. Take the max of all counters
|
|
|
|
|
|
|
|
|
|
TEMP=$(cat $TEMP_FILE)
|
|
|
|
|
TEMP=$(cat $TEMPERATURE_FILES 2>/dev/null | xargs -n1 | sort -g -r | head -1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
### END define script functions.
|
|
|
|
|
|
|
|
|
|
echo "Initialize to max CPU frequency"
|
|
|
|
|
unthrottle
|
|
|
|
|
|
|
|
|
|
# Mainloop
|
|
|
|
|
|
|
|
|
|
# Main loop
|
|
|
|
|
while true; do
|
|
|
|
|
get_temp # Gets the current tempurature and set it to the variable TEMP.
|
|
|
|
|
get_temp # Gets the current temperature and set it to the variable TEMP.
|
|
|
|
|
if [ $TEMP -gt $MAX_TEMP ]; then # Throttle if too hot.
|
|
|
|
|
throttle
|
|
|
|
|
elif [ $TEMP -le $LOW_TEMP ]; then # Unthrottle if cool.
|
|
|
|
|
unthrottle
|
|
|
|
|
fi
|
|
|
|
|
sleep 3 # The amount of time between checking tempuratures.
|
|
|
|
|
sleep 3 # The amount of time between checking temperatures.
|
|
|
|
|
done
|
|
|
|
|