Last active
December 9, 2018 17:25
-
-
Save loathingKernel/995777d2aab6dc82316ea2da62142975 to your computer and use it in GitHub Desktop.
This file contains 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 | |
#command="optirun -b none nvidia-settings -c :8" | |
command="nvidia-settings -c :0" | |
# fan speed offset from temperature value | |
offset=0 | |
# sets the refresh interval in seconds | |
interval=10 | |
# reset values upon termination | |
trap "{ | |
$command -a GPUFanControlState[gpu:0]=0 > /dev/null; | |
echo Disabled fan control; | |
exit 0; | |
}" SIGINT SIGTERM | |
# enable fan control | |
output=$($command -a GPUFanControlState[gpu:0]=1) | |
echo "Enabled fan control" | |
previous_temp=0 | |
while [ "1" -eq "1" ] | |
do | |
current_temp=$($command -t -q GPUCoreTemp[gpu:0] | tail -1) | |
if [ "$current_temp" != "$previous_temp" ] | |
then | |
previous_temp="$current_temp" | |
speed=$(($current_temp + $offset)) | |
# For nvidia drivers 340xx and below | |
#output=$($command -a GPUCurrentFanSpeed[fan:0]=$speed) | |
# For nvidia drivers above 340xx | |
output=$($command -a GPUTargetFanSpeed[fan:0]=$speed) | |
if [ "$1" == "-v" ] | |
then | |
echo "Fan speed: $(echo $output | awk -F' ' '{print $6}')" | |
fi | |
fi | |
sleep "$interval" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment