This is a C port of Stefan Hirschmann's NoteBook FanControl.
It provides the same utilities with the same interfaces as the original NBFC, although the implementation differs.
To check if your laptop is supported, use the Configuration Search.
If you want to write a configuration for your laptop model, see Configuration HowTo.
If you find my work helpful, you can show your appreciation by buying me a coffee.
- Comparison of NBFC C# and NBFC Linux
- Installation
- Getting started with the GUI
- Getting started without the GUI
- Advanced configuration
- Differences in detail
- Troubleshooting
- Advanced Compilation
- Shell autocompletion
- Contributing
| What | NBFC Mono | NBFC Linux |
|---|---|---|
| Portability | Crossplatform | Linux |
| Configuration files | XML (210 files) | JSON (297 files) |
| Model compatibility database | No | Yes |
| Runtime | Mono | Native |
| Memory consumption (ps_mem) | ~50MB | ~280KB |
| Package size (pkg.tar.gz) | 448K | 100K |
| Fan control rights | Any user | Any user |
| Service control rights | Any user | Only root |
| IPC Concept | TCP/IP | Unix sockets |
| IPC Protocol | Binary | JSON |
| Graphical User Interface | Windows only | Linux only |
The service, the client and the probing tool are written in C.
-
Arch Linux:
- Download Latest Version 0.3.19
- Install NBFC-Linux:
pacman -U ./nbfc-linux-git-0.3.18.r4.g656af52-1-x86_64.pkg.tar.zst - Or via AUR (
yay -S nbfc-linux) - Or by using the PKGBUILD nbfc-linux-git
-
Debian / Ubuntu:
- Download Latest Version 0.3.19
- Install NBFC-Linux:
apt install ./nbfc-linux_0.3.19_amd64.deb
-
Fedora:
- Download Latest Version 0.3.19
- Install NBFC-Linux:
dnf install ./fedora-nbfc-linux-0.3.19-1.x86_64.rpm
-
OpenSuse (Tumbleweed)
- Download Latest Version 0.3.19
- Install NBFC-Linux:
zypper install ./opensuse-nbfc-linux-0.3.19-1.x86_64.rpm
-
NixOS:
- Declaratively
- Imperatively (with
nix profile installornix-env -if .)
-
Fedora - this will not build the current working directory, but downloads a source archive from chosen release on github and builds an installable rpm:
- ensure, that podman is installed
- docker should work also, but is currently not tested
- edit pkgbuilds/rpm/nbfc-linux.spec and
- set wanted Version (e.g. 0.3.19)
- set wanted Releasenumber (e.g. 1%{?dist} or 2%{?dist})
./pkgbuilds/rpm/buildNBFC-LINUX- the resulting rpm can be found in pkgbuilds directory
- ensure, that podman is installed
-
In general:
./autogen.sh && ./configure --prefix=/usr --sysconfdir=/etc && make && sudo make install
-
For systems with OpenRC (gentoo):
./autogen.sh && ./configure --prefix=/usr --sysconfdir=/etc --with-init-system=openrc && make && sudo make install
-
For systems with System-V-Init:
./autogen.sh && ./configure --prefix=/usr --sysconfdir=/etc --with-init-system=systemv && make && sudo make install
Graphical User Interfaces are available as separate projects.
Currently there are two GUI implementations:
-
- Simple GUI written in Python based on Qt5/Qt6
- Comes with an extra tray application for controlling fans
-
- Simple GUI written in Python based on Gtk4
When running NBFC for the first time, you need to give it a configuration file for your laptop model.
Follow the steps below:
-
sudo nbfc updatewill download the latest configuration files from the internet. -
sudo nbfc config --set autowill try to set a configuration automatically.If this succeeds, skip to Step 5.
-
nbfc config --recommendwill compare your DMI system-product-name to the available configuration file names and print a list of descending similarity. -
Repeat the following until you found a working configuration:
-
sudo nbfc config --set "<MODEL>"-- set a configuration -
sudo nbfc restart -r-- (re-)start the service in read only mode -
nbfc status-- show the fan status -
Let the fan turn up (and down) (e.g. using
stress) and observe ifnbfc statusshows fan speed changes -
If speeds are reported correctly, the config is likely valid. Proceed to Step 5.
-
sudo nbfc restartwill (re-)start the service in write mode (enabling fan control) -
Test fan control manually
-
nbfc set -s <SPEED>will set the fan speed. (0=off,100=full speed)If this does not work, the specified configuration is invalid. Go back to Step 4.
-
nbfc set --autowill enable auto mode (temperature-based automatic fan speed control as specified in configuration) -
sudo systemctl enable nbfc_servicewill enable the service to start automatically on boot
NBFC-Linux allows you to specify which temperature sources to use for controlling fans and the algorithm to compute the temperature.
NOTE: Since version 0.3.3 NBFC-Linux also allows you to specify sensors in FanConfigurations using the
Sensorsfield
NOTE: The command
nbfc sensorsis available since version 0.3.16. If you are running a previous version, you can still configure it by hand.
Default Configuration
If no configuration is specified, NBFC uses the "Average" algorithm and utilizes all sensor files named "coretemp", "k10temp", or "zenpower".
Available Algorithms
You can choose from three different algorithms to compute the temperature:
- "Average": Computes the average temperature from all specified sources.
- "Min": Selects the lowest temperature among all specified sources.
- "Max": Selects the highest temperature among all specified sources.
Temperature Sources
You can specify temperature sources either by a
- sensor name (which may result in multiple temperature sources)
- temperature file: A file containing the temperature (usually named
temp*_input) - shell command: A command whose output is used as temperature (the command has to be prefixed by
$) - sensor group:
- @CPU: Uses all sensors named "coretemp", "k10temp" or "zenpower"
- @GPU: Uses all sensors named "amdgpu", "nvidia", "nouveau" or "radeon"
Specyfing Temperature Sources
-
nbfc sensors listwill output all available sensors -
nbfc sensors showwill show all available fans and their configured sensors -
sudo nbfc sensors set -f <FAN_INDEX> [-s <SENSOR>...] [-a <ALGORITHM>]will set the specified sensors and the algorithm for a fan.
Examples
-
sudo nbfc sensors set -f 0 -s coretemp -a MinFan 0 uses the "Min" algorithm with all sensors named "coretemp".
-
sudo nbfc sensors set -f 0 -s /sys/class/hwmon/hwmon4/temp1_input -s /sys/class/hwmon/hwmon4/temp2_inputFan 0 uses the default algorithm with the specific sensor file paths.
-
sudo nbfc sensors set -f 0 -s '$ echo 42'Fan 0 uses the output of echo 42 as temperature
-
sudo nbfc sensors set -f 1 -s @GPUFan 1 uses all sensors in the
@GPUgroup ("amdgpu", "nvidia", "nouveau", "radeon")
| Files | NBFC Mono | NBFC Linux |
|---|---|---|
| Systemd service file | nbfc.service | nbfc_service.service |
| EC Probing tool | ec-probe | ec_probe |
| Notebook configuration files | /opt/nbfc/Configs/*.xml | /usr/share/nbfc/configs/*.json |
| Service binary | /opt/nbfc/nbfcservice.sh | /bin/nbfc_service |
| PID File | /run/nbfc.pid | /run/nbfc_service.pid |
| Config file | ? | /etc/nbfc/nbfc.json |
-
The original NBFC service adjusts the fan speeds in intervals of
EcPollIntervallaccording toTemperatureThresholds. - NBFC Linux directly sets the fan speed (also according toTemperatureThresholds). -
The original NBFC service selects a TemperatureThreshold and applies its
FanSpeedwhen the temperature exceeds itsUpThreshold. In contrast, NBFC Linux will select the next TemperatureThreshold and apply itsFanSpeedwhen the temperature exceeds the currentUpThreshold. The provided config files have been reconfigured to account for this change, so that they provide the same behaviour as the original NBFC service. If you have a custom config file that works well with the original service, you can port it to NBFC Linux using the provided tool (requires python3-lxml). -
NBFC Linux dropped the
Autostartoption, since it relies on the systemd service file only.
The preferred way of running nbfc is using the ECSysLinux implementation, which depends on the ec_sys kernel module.
There is also an alternative implementation which uses /dev/port, called dev_port.
It can be specified on the commandline using --embedded-controller=dev_port and permanently set in /etc/nbfc/nbfc.json with "EmbeddedControllerType": "dev_port".
Many Linux distributions do not provide the ec_sys module, and the module should be compiled manually. Alternatively, the acpi_ec module can be used. The acpi_ec module comes with a DKMS config script, which automatically rebuilds the acpi_ec module when a new kernel is installed and supports running NBFC with Secure Boot and Lockdown Kernel. NBFC-Linux will try to use the acpi_ec module if available. It can be set with "EmbeddedControllerType": "acpi_ec".
NBFC-Linux allows disabling features at compile time to produce an even smaller binary.
Pass the following flags to ./configure to disable specific components.
--disable-syslog: Don't log to syslog in daemon mode--disable-ec-debug: Disable debugging of reads/writes from/to the embedded controller--disable-ec-dummy: Disable the dummy embedded controller implementation--disable-ec-dev-port: Disable the /dev/port embedded controller implementation--disable-ec-sys: Disable the embedded controller implementation that relies onec_syskernel module--disable-ec-acpi: Disable the embedded controllern implementation that relies on theacpi_eckernel module
See Configure Command Generator for an interactive interface to generate the ./configure command.
NBFC-Linux comes with shell completion scripts for bash, fish and zsh.
The completion files are generated using crazy-complete.
~ $ nbfc_service <TAB>
--config-file -c -- Use alternative config file (default /etc/nbfc/nbfc.json)
--debug -d -- Enable tracing of reads and writes of the embedded controller
--embedded-controller -e -- Specify embedded controller to use
--fork -f -- Switch process to background after sucessfully started
--help -h -- show this help message and exit
--read-only -r -- Start in read-only mode
~ $ nbfc <TAB>
config -- List or apply configs
donate -- Show how to support the project
get-model-name -- Print model name for notebook
help -- Show help
restart -- Restart the service
sensors -- Configure fan sensors
set -- Control fan speed
start -- Start the service
status -- Show the service status
stop -- Stop the service
update -- Download new configuration files
warranty -- Show warranty
You can write a configuration file for your laptop model. See the Wiki of the original NBFC for more details.
Please do not create issues on GitHub requesting a configuration file for your laptop!
If you found a working configuration for your laptop model, you can register it in the Compatibility Database.
If you want to write a program that controls the NBFC service, see the protocol.
Developers are welcome to try optimizing the code of the service for memory usage. However, be warned that it is likely a waste of time, as the author has already tried every possible approach. It seems that every line of code is necessary for the current functionality.
See also the documentation about the nbfc configuration.