diff options
| author | Sepero <sepero111@gmail.com> | 2013-12-11 01:49:15 -0500 |
|---|---|---|
| committer | Sepero <sepero111@gmail.com> | 2013-12-11 01:49:15 -0500 |
| commit | 17a25af364d831b551008ff5d3bccde8becce3a1 (patch) | |
| tree | 188cec9a018e676cb57f62e6577d44f60b375746 | |
| parent | 34a8ec03f4dba0229812c4513df514bab553dc9c (diff) | |
Implemented automatic discovery of temperature reading location.
| -rw-r--r-- | README.md | 4 | ||||
| -rw-r--r-- | temp_throttle.sh | 33 |
2 files changed, 28 insertions, 9 deletions
@@ -23,5 +23,5 @@ Links: http://seperohacker.blogspot.com/2012/10/linux-keep-your-cpu-cool-with-fr License: GNU GPL 2.0 -Usage: temp_throttle.sh max_temp -USE CELSIUS TEMPERATURES. +Usage: `temp_throttle.sh max_temp` +USE CELSIUS TEMPERATURES diff --git a/temp_throttle.sh b/temp_throttle.sh index 397def1..847ffc5 100644 --- a/temp_throttle.sh +++ b/temp_throttle.sh @@ -2,7 +2,7 @@ # Usage: temp_throttle.sh max_temp # USE CELSIUS TEMPERATURES. -# version 2.01 +# version 2.10 cat << EOF Author: Sepero 2013 (sepero 111 @ gmx . com) @@ -12,7 +12,6 @@ URL: http://github.com/Sepero/temp-throttle/ EOF # Additional Links -# http://github.com/Sepero/temp-throttle/ # http://seperohacker.blogspot.com/2012/10/linux-keep-your-cpu-cool-with-frequency.html # Additional Credits @@ -71,6 +70,30 @@ FREQ_LIST_LEN=$(echo $FREQ_LIST | wc -w) # CURRENT_FREQ will save the index of the currently used frequency in FREQ_LIST. CURRENT_FREQ=2 +# This is a list of possible locations to read the current system temperature. +TEMPERATURE_FILES=" +/sys/class/thermal/thermal_zone0/temp +/sys/class/thermal/thermal_zone1/temp +/sys/class/thermal/thermal_zone2/temp +/sys/class/hwmon/hwmon0/temp1_input +/sys/class/hwmon/hwmon1/temp1_input +/sys/class/hwmon/hwmon2/temp1_input +/sys/class/hwmon/hwmon0/device/temp1_input +/sys/class/hwmon/hwmon1/device/temp1_input +/sys/class/hwmon/hwmon2/device/temp1_input +null +" + +# Store the first temperature location that exists in the variable TEMP_FILE. +# The location stored in $TEMP_FILE will be used for temperature readings. +for file in $TEMPERATURE_FILES; do + TEMP_FILE=$file + [ -f $TEMP_FILE ] && break +done + +[ $TEMP_FILE == "null" ] && err_exit "The location for temperature reading was not found." + + ### End Initialize Global variables. @@ -103,12 +126,8 @@ unthrottle () { get_temp () { # Get the system temperature. - # If one of these doesn't work, the try uncommenting another. - TEMP=$(cat /sys/class/thermal/thermal_zone0/temp) - #TEMP=$(cat /sys/class/hwmon/hwmon0/temp1_input) - #TEMP=$(cat /sys/class/hwmon/hwmon1/temp1_input) - #TEMP=$(cat /sys/class/hwmon/hwmon1/device/temp1_input) + TEMP=$(cat $TEMP_FILE) } # Mainloop |
