#!/bin/sh # ############################################################################### # Copyright (C) 2005 Francois COJEAN # Copyleft 2007 Sun Seng David TAN # 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 2 # 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, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ############################################################################### # this script change the CPU governor according to the temperature detected. # Note : this script need to be run as root. # TODO : maybe use inotify # Set up the different variables # Edit all this variable to value which fit to your computer POWERSAVE_SCALING_GOVERNOR="powersave" CONSERVATIVE_SCALING_GOVERNOR="conservative" ONDEMAND_SCALING_GOVERNOR="ondemand" CPU_FREQ_PATH="/sys/devices/system/cpu/cpu0/cpufreq" SCALING_GOVERNOR_FILE="scaling_governor" TEMPERATURE_ACPI_PATH="/proc/acpi/thermal_zone/TZS0" TEMPERATURE_MAX=87 TEMPERATURE_SAFE=73 while true; do TEMPERATURE="`cat $TEMPERATURE_ACPI_PATH/temperature |cut -d' ' -f14`" echo $TEMPERATURE if [ $TEMPERATURE -gt $TEMPERATURE_MAX ] then echo "$POWERSAVE_SCALING_GOVERNOR" > $CPU_FREQ_PATH/$SCALING_GOVERNOR_FILE echo "CPU_FREQ : $POWERSAVE_SCALING_GOVERNOR enable" fi if [ $TEMPERATURE -lt $TEMPERATURE_SAFE ] then echo "$ONDEMAND_SCALING_GOVERNOR" > $CPU_FREQ_PATH/$SCALING_GOVERNOR_FILE echo "CPU_FREQ : $ONDEMAND_SCALING_GOVERNOR enable" fi sleep 1 done