Last active
December 19, 2015 08:09
-
-
Save omniwired/5924196 to your computer and use it in GitHub Desktop.
Changes GPU profile based on temperature also set CPU on powersave if it's too hot. keywords: amd, ati, open driver, linux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#CPU | |
TARGET_GPU='83000'; | |
TARGET_CPU='83000'; | |
SENSOR_DATA=$(more /sys/class/drm/card0/device/drm/card0/device/hwmon/hwmon1/temp1_input); | |
#CPU | |
cpu_temp[0]=$(more /sys/bus/platform/devices/coretemp.0/temp2_input); | |
cpu_temp[1]=$(more /sys/bus/platform/devices/coretemp.0/temp3_input); | |
cpu_temp[2]=$(more /sys/bus/platform/devices/coretemp.0/temp4_input); | |
cpu_temp[3]=$(more /sys/bus/platform/devices/coretemp.0/temp5_input); | |
avg_cpu_temp=0; | |
for (( i = 0; i < 4; i++ )); do | |
let "avg_cpu_temp += cpu_temp[i]"; | |
done | |
let "avg_cpu_temp /= 4"; | |
function common { | |
cat /sys/kernel/debug/dri/0/radeon_pm_info; | |
echo "cpu temp $avg_cpu_temp"; | |
} | |
if [[ $SENSOR_DATA<$TARGET_GPU ]]; then | |
echo "auto mode $SENSOR_DATA"; | |
echo auto > /sys/class/drm/card0/device/power_profile; | |
common | |
else | |
echo "low mode $SENSOR_DATA"; | |
echo low > /sys/class/drm/card0/device/power_profile; | |
common | |
fi; | |
#CPU stuff | |
if [[ $avg_cpu_temp<$TARGET_CPU ]]; then | |
echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor; | |
else | |
echo powersave > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor; | |
echo "CPU governor powersave" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment