Skip to content

Instantly share code, notes, and snippets.

@radiaku
Last active May 28, 2025 06:28
Show Gist options
  • Save radiaku/41bb687c4c1d07d00aa87ce13dc4672f to your computer and use it in GitHub Desktop.
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 )
#!/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
@radiaku
Copy link
Author

radiaku commented May 28, 2025

Update:

sudo vim /etc/systemd/system/i8kmon.service

[Unit]
Description=Dell Fan Control Daemon (i8kmon)
After=multi-user.target

[Service]
Type=simple
ExecStart=/usr/bin/i8kmon
Restart=on-failure
User=root

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable --now i8kmon.service
sudo systemctl status i8kmon.service

@radiaku
Copy link
Author

radiaku commented May 28, 2025

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