Last active
May 28, 2025 06:28
-
-
Save radiaku/41bb687c4c1d07d00aa87ce13dc4672f to your computer and use it in GitHub Desktop.
custom fan control using i8kctl on alienware m15 with cachyos ( arch based 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/bash | |
# LOG_FILE="~/fan_control.log" | |
# Initialize last fan state | |
LAST_LEFT=-1 | |
LAST_RIGHT=-1 | |
while true; do | |
# Get CPU temperature | |
CPU_TEMP=$(sensors | awk '/^CPU:/ { gsub(/\+|°C/, "", $2); print int($2) }') | |
# Get GPU temperature | |
GPU_TEMP=$(nvidia-smi --query-gpu=temperature.gpu --format=csv,noheader,nounits) | |
# Default fan levels | |
LEFT=0 # CPU fan | |
RIGHT=0 # GPU fan | |
# Determine CPU fan speed | |
if (( CPU_TEMP < 80 )); then | |
LEFT=1 # Medium | |
else | |
LEFT=2 # High | |
fi | |
# Determine GPU fan speed | |
if (( GPU_TEMP < 70 )); then | |
RIGHT=1 # Medium | |
else | |
RIGHT=2 # High | |
fi | |
# Apply fan settings only if changed | |
if [[ "$LEFT" -ne "$LAST_LEFT" ]]; then | |
sudo /usr/bin/i8kctl fan1 $LEFT | |
LAST_LEFT=$LEFT | |
fi | |
if [[ "$RIGHT" -ne "$LAST_RIGHT" ]]; then | |
sudo /usr/bin/i8kctl fan2 $RIGHT | |
LAST_RIGHT=$RIGHT | |
fi | |
echo "$(date): CPU Temp: $CPU_TEMP°C, GPU Temp: $GPU_TEMP°C, CPU Fan: $LEFT, GPU Fan: $RIGHT" >> $LOG_FILE | |
sleep 5 | |
done |
Bonus::
i8kctl fan
can't find package i8k::thermal
while executing
"package require i8k::thermal"
(file "/usr/bin/i8kctl" line 25)
sudo vim /usr/bin/i8kctl
lappend auto_path /usr/lib/tcl8/8.6
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Update:
sudo vim /etc/systemd/system/i8kmon.service