A simple daemon providing dynamic fan speed control based on temperature sensors.
A simple daemon providing dynamic fan speed control based on temperature sensors.
fan2go
A daemon to control the fans of your computer.
fan2go is first and foremost a daemon that runs in the background. However, it also provides a small set of CLI commands (see CLI Commands) as well as an optional local HTTP API to allow external programs to interact with it. This API can be used to create UI clients or other tools.
fan2go-tui - (Official) Terminal UI for fan2go.
fan2go relies on lm-sensors to get both temperature and RPM sensor readings, as well as PWM controls, so you will have to set it up first.
yay -S fan2go-gitCommunity Maintained Packages
nix profile install nixpkgs#fan2gonix-env -f '' -iA fan2goSee: https://github.com/johnwbyrd/fan2go-package/
Download the latest release from GitHub:
# Install dependencies
sudo pacman -S libnotify
curl -L -o fan2go https://github.com/markusressel/fan2go/releases/latest/download/fan2go-linux-amd64
chmod +x fan2go
sudo cp ./fan2go /usr/bin/fan2go
fan2go -hOr compile yourself:
git clone https://github.com/markusressel/fan2go.git
cd fan2go
make build
sudo cp ./bin/fan2go /usr/bin/fan2go
sudo chmod ug+x /usr/bin/fan2goThen configure fan2go by creating a YAML configuration file in one of the following locations:
/etc/fan2go/fan2go.yaml (recommended)/root/.fan2go/fan2go.yaml./fan2go.yamlsudo mkdir /etc/fan2go
sudo nano /etc/fan2go/fan2go.yamlThe most important configuration options you need to define are the fans:, sensors: and curves: sections.
Under fans: you need to define a list of fan devices that you want to control using fan2go. To detect fans on your
system run fan2go detect, which will print a list of devices exposed by the hwmon filesystem backend:
…The hwmon fan index is based on device enumeration and is not stable for a given fan if hardware configuration
changes.
The Linux kernel hwmon channel is a better identifier for configuration as it is largely based on the fan headers
in use.
Fan RPM, PWM, and temperature sensors are independent and Linux does not associate them automatically. A given PWM may control more than one fan, and a fan may not be under the control of a PWM. By default, fan2go guesses and sets the pwm channel number for a given fan to the fan's RPM sensor channel. You can override this in the config.
For nvidia devices, the fan index is stable.
Note that it can happen that the hardware only gives limited control over a fan and it, for example, always runs with at least 30% speed - even if in automatic mode the hardware may make it stop entirely if the temperature is low enough.
To use detected hwmon devices in your configuration, use the hwmon fan type:
…To use detected NVIDIA GPUs in your configuration, use the nvidia fan type:
fans:
- id: gpufan1
nvidia:
# A regex matching a nvidia device as displayed by `fan2go detect`
# the following matches all nvidia devices in your system
# (good enough if you only have one), otherwise you could
# also use nvidia-10DE2489-0800 or similar
device: nvidia
# The fan's index as shown by `fan2go detect`
index: 1
curve: gpu_curve
# same for the second fan
- id: gpufan2
nvidia:
device: nvidia
index: 2
curve: gpu_curveNote that the fan speed can only be controlled for GPUs of the "Maxwell" generation (Geforce 9xx) and newer, and that reading the fan speed in RPM requires nvidia driver 565 or newer.
fans:
- id: file_fan
file:
# Path to a file to get/set the PWM target for this fan
path: /tmp/file_fan
# Path to a file to read the current RPM value of this fan
rpmPath: /tmp/file_fan_rpm> cat /tmp/file_fan
255
> cat /tmp/file_fan_rpm
3421Please also make sure to read the section about considerations for using the cmd sensor/fan.
fans:
- id: cmd_fan
cmd:
# Command to apply a new PWM value (0..255)
# Use "%pwm%" to specify where the target pwm value should be used within the arguments
setPwm:
exec: /usr/bin/some-program
args: [ "--set", "%pwm%" ]
# Command to retrieve the current PWM value (0..255)
getPwm:
exec: /usr/bin/nvidia-settings
args: [ "-a", "someargument" ]
# (optional) Command to retrieve the current RPM value
getRpm:
exec: /usr/bin/nvidia-settings
args: [ "-a", "someargument" ]Reads the temperature of a block device (SATA, NVMe, etc.) using a stable device path instead of an hwmon platform index that can change across reboots.
sensors:
- id: ssd_temp
disk:
# Full path (recommended for clarity)
device: /dev/disk/by-id/ata-Samsung_SSD_870_EVO_1TB_S1234567890
# Short form also accepted (prefix /dev/disk/by-id/ is auto-applied):
# device: ata-Samsung_SSD_870_EVO_1TB_S1234567890
# The /dev/ prefix is also optional (e.g. just "sda"):
# device: sda
- id: nvme_temp
disk:
device: /dev/disk/by-id/nvme-Samsung_SSD_980_1TB_S1234567890
# Short form: device: nvme-Samsung_SSD_980_1TB_S1234567890Requires the drivetemp kernel module for SATA drives (standard since kernel 5.6) or nvme-hwmon
for NVMe (standard since kernel 4.15). Falls back to a direct ATA SMART ioctl for SATA drives
without drivetemp loaded.
If the automatic fan curve analysis doesn't provide a good enough estimation for how the fan behaves, you can use the following configuration options (per fan definition) to correct it:
…Under sensors: you need to define a list of temperature sensor devices that you want to monitor and use to adjust
fanspeeds. Like with fans, you can find usable devices using fan2go detect.
# A list of sensors to monitor
sensors:
# A user defined ID, which is used to reference
# a sensor in a curve configuration (see below)
- id: cpu_package
# The type of sensor configuration, one of: hwmon | nvidia | file | cmd | disk
hwmon:
# A regex matching a controller platform displayed by `fan2go detect`, f.ex.:
# "coretemp", "it8620", "corsaircpro-*" etc.
platform: coretemp
# The index of this sensor as displayed by `fan2go detect`
index: 1sensors:
- id: gpu_temp
nvidia:
# A regex matching a nvidia device as displayed by `fan2go detect`
device: nvidia-10DE2489-0800
# The index of this sensor as displayed by `fan2go detect`
# (currently NVIDIA/nvml exposes only a single temperature sensor per GPU)
index: 1sensors:
- id: file_sensor
file:
# Path to the file containing sensor values
path: /tmp/file_sensorThe file contains a value in milli-units, like f.ex. milli-degrees.
> cat /tmp/file_sensor
10000Please also make sure to read the section about considerations for using the cmd sensor/fan.
Just like the file sensor, the command must output the sensor value in milli-units,
like f.ex. milli-degrees.
sensors:
- id: cmd_fan
cmd:
# Path to the executable to run to retrieve the current sensor value
exec: /usr/bin/bash
# (optional) arguments to pass to the executable
args: [ '/home/markus/myscript.sh' ]Under curves: you need to define a list of fan speed curves, which represent the speed of a fan based on one or more
temperature sensors.
Speed values: Curve values range from
0to255(equivalently0%to100%). By default, fan2go scales these to the fan's detected (or configured)minPwm..maxPwmrange:
0/0%→ fan off (unlessneverStop: true, in which case the fan is held atminPwm)1..255/1%..100%→ linearly mapped tominPwm..maxPwmTo use curve values as raw PWM values without scaling, set
useUnscaledCurveValues: truein the fan config.
To create a linear speed curve, use a curve of type linear.
This curve type can be used with a min/max sensor value, where the min temp will result in a curve value of 0 and the
max temp will result in a curve value of 255:
curves:
- id: cpu_curve
# The type of the curve, one of: linear | function
linear:
# The sensor ID to use as a temperature input
sensor: cpu_package
# Sensor input value (in degrees Celsius)
# at which the curve is at minimum speed
min: 40
# Sensor input value at which the curve is at maximum speed
max: 80You can also define the curve in multiple, linear sections using the steps parameter,
where the left side refers to the sensor input value and the right side refers to the curve value at that sensor input.
…NOTE: When using
useUnscaledCurveValuesin the fan configuration, the values specified in the curve are **not scaled ** to the [MinPwm..MaxPwm] range of the fan, but are directly mapped with thepwmMap(if specified) or used as is (if nopwmMapis specified and a 1:1 mapping is assumed). In this case, it is recommended to specify curve values in the same range as the expected PWM values after scaling to avoid confusion. So if your fan has a MinPwm of 30 and a MaxPwm of 255, you should specify curve values in the [30..255] range.
Alternatively the speeds can be specified in [0..255] range:
curves:
- id: cpu_curve
# The type of the curve
linear:
# The sensor ID to use as a temperature input
sensor: cpu_package
# Steps to define a section-wise defined speed curve function.
steps:
# Sensor value (in degrees Celsius) -> Speed (0-255)
- 40: 0
- 41: 1
- 50: 50
- 80: 255To create a staircase speed curve, use a curve of type staircase.
It maintains static fan speeds at defined temperature ranges. This prevents fans from constantly ramping up and down (oscillating) in response to minor, rapid fluctuations in sensor temperature, offering a more consistent acoustic profile.
curves:
- id: staircase_curve
staircase:
sensor: cpu_package
hysteresis:
down: 6
steps:
# Sensor value (in degrees Celsius) -> Speed (0-255)
- 40: 1
- 50: 50
- 80: 255If you want to get your hands dirty and use a PID based curve, you can use pid:
curves:
- id: pid_curve
pid:
sensor: cpu_package
setPoint: 60
p: -0.05
i: -0.005
d: -0.005Unlike the other curve types, this one does not use the average of the sensor da
No open issues yet, or sync has not completed.