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 |
If got error like this
$ i8kmon --help
can't find package cmdline 1.5
while executing
"package require cmdline 1.5"
(file "/usr/bin/i8kmon" line 20)
run this to search cmdline
pacman -Ql tcllib | grep cmdline.tcl
usually you got
/usr/lib/tcllib/cmdline/cmdline.tcl
then edit it
/usr/bin/i8kmon
add this to before import
lappend auto_path /usr/lib/tcllib
or you can test
lappend auto_path /usr/lib/tcllib
package require cmdline 1.5
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
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 , after install fancontrol_ui
I dont know what happen, but now fan1 not working.
you need
if on
/usr/local/bin/i8kctl
just replace the old