All Discussions > Steam Forums > Off Topic > Topic Details
looking for someone with programing experience (gpu fan control)
im gaming on linux and my default fan speeds are awful and its cooking my gpu. i am an idiot with no training or education and i cooked up the following script, does it look safe and usable?

theres a few other terminal inputs needed before implement that i havent included yet just auditing the script itself first

#!/bin/bash

HWMON_PATH="/sys/class/hwmon/hwmon4"
TEMP_FILE="$HWMON_PATH/temp2_input"
PWM_FILE="$HWMON_PATH/pwm1"
PWM_ENABLE_FILE="$HWMON_PATH/pwm1_enable"
PWM_MAX=$(cat "$HWMON_PATH/pwm1_max")

# Restore automatic fan control on exit
cleanup() {
echo "Restoring automatic fan control..."
echo 2 | sudo tee "$PWM_ENABLE_FILE" > /dev/null
exit
}
trap cleanup SIGINT SIGTERM

# Enable manual control
echo 1 | sudo tee "$PWM_ENABLE_FILE" > /dev/null

while true; do
TEMP_MIL=$(cat "$TEMP_FILE")
TEMP=$(( TEMP_MIL / 1000 ))

if [ "$TEMP" -ge 80 ]; then
PWM_VAL=$PWM_MAX
elif [ "$TEMP" -ge 70 ]; then
PWM_VAL=$(( PWM_MAX * 75 / 100 ))
elif [ "$TEMP" -ge 60 ]; then
PWM_VAL=$(( PWM_MAX * 50 / 100 ))
elif [ "$TEMP" -ge 44 ]; then
PWM_VAL=$(( PWM_MAX * 25 / 100 ))
else
PWM_VAL=0
fi

echo "$PWM_VAL" | sudo tee "$PWM_FILE" > /dev/null
echo "Temp: ${TEMP}°C, Setting fan PWM to $PWM_VAL"

sleep 5
done
Last edited by ameko; 19 Jul @ 12:18am
< >
Showing 1-3 of 3 comments
i don't understand why one wouldn't let the motherboard take the wheel on this and set it from the bios?
ameko 18 Jul @ 11:27pm 
Originally posted by Hammer Of Evil:
i don't understand why one wouldn't let the motherboard take the wheel on this and set it from the bios?

id love to, but my msi x670e has no gpu fan or power controls. ive looked many times
Originally posted by ameko:
Originally posted by Hammer Of Evil:
i don't understand why one wouldn't let the motherboard take the wheel on this and set it from the bios?

id love to, but my msi x670e has no gpu fan or power controls. ive looked many times

oh my mistake!! i missed the part where you said 'gpu', carry on.
< >
Showing 1-3 of 3 comments
Per page: 1530 50

All Discussions > Steam Forums > Off Topic > Topic Details