A lightweight bash script for automatic temperature-based fan control arch\fedora based Linux systems with PWM fan support.
- Zero Dependencies - Pure bash, no Python or other interpreters needed
- Lightweight - Only 2-5 MB memory footprint
- Auto-Detection - Automatically finds all temperature sensors and fan controls
- Multi-OS Support - Works on Arch Linux, Bazzite, Fedora, Ubuntu, and more
- Smart Installer - Detects your distro and installs dependencies automatically
- Systemd Integration - Runs as a service with auto-start on boot
- Configurable - Easy-to-edit temperature thresholds and fan speeds
- Safe - Resets fans to automatic mode on exit
- Why This Exists
- Requirements
- Installation
- Usage
- Configuration
- Troubleshooting
- How It Works
- Contributing
- License
The Corsair AI Workstation 300 has a front performance button that controls fan profiles, but it only works with the Windows iCUE software. On Linux, you lose this functionality. This script provides automatic fan control based on system temperatures, giving you fine-tuned control over cooling and noise levels.
While Linux systems have built-in thermal protection and won't overheat without this script, custom fan control allows you to:
- Reduce noise during light workloads
- Increase cooling during heavy tasks
- Set your own temperature/noise balance
- React faster to temperature changes than BIOS curves
- Linux kernel with hwmon support (standard on all modern distros)
- Bash 4.0 or higher (pre-installed on all modern Linux systems)
lm-sensorspackage (automatically installed by the installer)- PWM fan controls exposed via
/sys/class/hwmon/ - Root/sudo access for installation and fan control
The installer automatically detects and supports:
- Arch Linux (and derivatives: Manjaro, EndeavourOS)
- Bazzite (Fedora Atomic/immutable)
- Fedora (regular and Atomic variants)
- Ubuntu/Debian (and derivatives)
- openSUSE/SLES
# Download and extract
tar -xzf corsair-ai300-fan-controller-bash.tar.gz
cd corsair-ai300-fan-controller-bash
# Run the installer (auto-detects your OS and installs dependencies)
sudo ./install_fan_controller_bash.sh
# Start the service
sudo systemctl start fan-controller-bash.serviceThat's it! The installer will:
- Detect your Linux distribution
- Install
lm-sensorsusing your package manager - Configure sensors automatically
- Install the fan controller script
- Set up the systemd service
- Enable auto-start on boot
On immutable systems (Bazzite), the installer will:
- Install
lm-sensorsviarpm-ostree - Prompt you to reboot
- After reboot, run the installer again to complete setup
This is normal for immutable distributions.
If you prefer to install manually:
# Install lm-sensors for your distro
# Arch:
sudo pacman -S lm_sensors
# Fedora:
sudo dnf install lm_sensors
# Ubuntu/Debian:
sudo apt install lm-sensors
# Bazzite:
rpm-ostree install lm_sensors && systemctl reboot
# Configure sensors
sudo sensors-detect --auto
# Install the script and service
sudo cp temp_fan_controller.sh /usr/local/bin/
sudo chmod +x /usr/local/bin/temp_fan_controller.sh
sudo cp fan-controller-bash.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable fan-controller-bash.service
sudo systemctl start fan-controller-bash.service# Start
sudo systemctl start fan-controller-bash.service
# Stop
sudo systemctl stop fan-controller-bash.service
# Restart
sudo systemctl restart fan-controller-bash.service
# Check status
sudo systemctl status fan-controller-bash.service# Follow logs in real-time
sudo journalctl -u fan-controller-bash.service -f
# View last 50 lines
sudo journalctl -u fan-controller-bash.service -n 50Expected output:
[2026-02-19 10:30:45] === Starting Automatic Fan Controller ===
[2026-02-19 10:30:45] Detecting temperature sensors...
[2026-02-19 10:30:45] Found: k10temp - temp1_input (Tdie)
[2026-02-19 10:30:45] Detected 1 temperature sensor(s)
[2026-02-19 10:30:45] Detecting fan PWM controls...
[2026-02-19 10:30:45] Found: it8792 - pwm1
[2026-02-19 10:30:45] Detected 1 fan control(s)
[2026-02-19 10:30:45] Starting monitoring loop...
[2026-02-19 10:30:45] Temperature: 45°C -> Setting fan speed to 30%
[2026-02-19 10:35:22] Temperature: 68°C -> Setting fan speed to 75%
Run the script manually to see what it detects:
sudo ./temp_fan_controller.shPress Ctrl+C to stop. The script will automatically reset fans to automatic mode.
# Enable auto-start on boot
sudo systemctl enable fan-controller-bash.service
# Disable auto-start
sudo systemctl disable fan-controller-bash.serviceEdit the configuration variables at the top of the script:
sudo nano /usr/local/bin/temp_fan_controller.sh# Temperature thresholds (°C)
TEMP_LOW=50 # Below 50°C - minimum fan speed
TEMP_MEDIUM=65 # 50-65°C - medium fan speed
TEMP_HIGH=75 # 65-75°C - high fan speed
TEMP_CRITICAL=85 # Above 85°C - maximum fan speed
# Fan speeds (%)
FAN_SPEED_LOW=30 # 30% fan speed
FAN_SPEED_MEDIUM=50 # 50% fan speed
FAN_SPEED_HIGH=75 # 75% fan speed
FAN_SPEED_CRITICAL=100 # 100% fan speed
# Check interval (seconds)
CHECK_INTERVAL=5 # Check every 5 seconds| Temperature | Fan Speed | Use Case |
|---|---|---|
| < 50°C | 30% | Idle/light tasks - quiet operation |
| 50-65°C | 50% | Normal use - balanced |
| 65-75°C | 75% | Heavy workload - prioritize cooling |
| > 85°C | 100% | Critical - maximum cooling |
Quiet Profile (prioritize silence):
TEMP_LOW=55
TEMP_MEDIUM=70
TEMP_HIGH=80
TEMP_CRITICAL=90
FAN_SPEED_LOW=25
FAN_SPEED_MEDIUM=40
FAN_SPEED_HIGH=65
FAN_SPEED_CRITICAL=100Aggressive Profile (prioritize cooling):
TEMP_LOW=45
TEMP_MEDIUM=60
TEMP_HIGH=70
TEMP_CRITICAL=80
FAN_SPEED_LOW=40
FAN_SPEED_MEDIUM=60
FAN_SPEED_HIGH=85
FAN_SPEED_CRITICAL=100After editing, restart the service:
sudo systemctl restart fan-controller-bash.servicesensorsExpected output:
k10temp-pci-00c3
Adapter: PCI adapter
Tctl: +45.0°C
Tdie: +45.0°C
Run sensor detection:
sudo sensors-detect
# Answer YES to all questions
sudo systemctl restart lm_sensors
sensorsfind /sys/class/hwmon -name "temp*_input"You should see files like:
/sys/class/hwmon/hwmon2/temp1_input
/sys/class/hwmon/hwmon2/temp2_input
find /sys/class/hwmon -name "pwm[0-9]" -not -name "*_enable"You should see files like:
/sys/class/hwmon/hwmon3/pwm1
/sys/class/hwmon/hwmon3/pwm2
If no PWM controls are found, your system may:
- Use BIOS-only fan control
- Require specific kernel modules
- Use a different control interface
Try loading common fan control modules:
sudo modprobe it87
sudo modprobe nct6775Then check again:
find /sys/class/hwmon -name "pwm*"Check the service logs:
sudo journalctl -u fan-controller-bash.service -n 50Common issues:
- lm-sensors not installed → Run the installer again
- No sensors detected → Run
sudo sensors-detect - No PWM controls → Your hardware may not support software fan control
- Permission denied → Make sure the service is running as root (it should be automatically)
Run manually to see detailed detection output:
sudo ./temp_fan_controller.shThis shows exactly which sensors and fan controls were detected.
- Scans
/sys/class/hwmon/hwmon*/directories - Finds all
temp*_inputfiles (temperature sensors) - Finds all
pwm*files with correspondingpwm*_enablefiles - Validates write permissions
- Reads all temperature sensors every 5 seconds
- Determines the highest temperature
- Calculates appropriate fan speed based on thresholds
- Only updates PWM when speed needs to change (reduces unnecessary writes)
- Sets
pwm*_enableto1(manual/PWM mode) - Writes PWM value (0-255) to
pwm*file - PWM percentage = (value / 255) × 100
- Catches SIGINT (Ctrl+C) and SIGTERM signals
- Resets
pwm*_enableto2(automatic mode) - Returns fan control to system/BIOS
| Metric | Impact |
|---|---|
| Memory Usage | 2-5 MB |
| CPU Usage | <0.1% (sleeps 95% of the time) |
| Disk I/O | Minimal (only sysfs reads) |
| Network | None |
This is negligible even on low-power systems.
| Feature | Bash | Python |
|---|---|---|
| Memory | 2-5 MB | 10-15 MB |
| Startup | Instant | ~100ms |
| Dependencies | None (built-in) | Python 3 interpreter |
| Best For | System daemons | Development/complex logic |
For a simple monitoring daemon, bash is more appropriate and efficient.
The systemd service includes hardening options:
NoNewPrivileges=true- Prevents privilege escalationPrivateTmp=true- Isolated /tmp directory
The script:
- Only reads from
/sys/class/hwmon/ - Only writes to PWM control files
- No network access
- No arbitrary file system access
# Stop and disable service
sudo systemctl stop fan-controller-bash.service
sudo systemctl disable fan-controller-bash.service
# Remove files
sudo rm /etc/systemd/system/fan-controller-bash.service
sudo rm /usr/local/bin/temp_fan_controller.sh
# Reload systemd
sudo systemctl daemon-reload
# Optionally remove lm-sensors (Arch example)
sudo pacman -Rs lm_sensorsContributions are welcome! Here are some ideas:
- Individual fan control (different speeds per fan)
- Hysteresis to prevent rapid speed changes
- Configuration file support
- Web interface for monitoring
- Email/notification alerts on high temps
- Support for more exotic hardware
- Better error handling
Feel free to open issues or submit pull requests!
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.
See https://www.gnu.org/licenses/gpl-3.0.en.html for details.
Originally created for the Corsair AI Workstation 300 mini PC, but designed to work on any Linux system with standard hwmon PWM fan controls.
If you encounter issues:
- Check the Troubleshooting section
- Run the script manually with
sudo ./temp_fan_controller.shto see detailed output - Check logs with
sudo journalctl -u fan-controller-bash.service -n 50 - Open an issue on GitHub with:
- Your distro and kernel version (
uname -a) - Output of
sensors - Output of
ls -la /sys/class/hwmon/*/pwm* - Relevant log snippets
- Your distro and kernel version (
This software comes with no warranty. While it includes safety features (automatic reset to BIOS control on exit, thermal throttling still active), use at your own risk. Monitor your system temperatures when first using this script to ensure it's working as expected for your hardware.
Made with ❤️ for the Linux community