Skip to content

This repository contains scripts and configuration files to control fan speed on my laptop.

License

Notifications You must be signed in to change notification settings

ERFouX/hp-fan-control

Repository files navigation

Warning

nbfc-ac-event.rules can affect your boot speed and slow down the boot process. If you have this problem, use the smart script manually.

I will update this entire repository soon and fix the problems.

HP EliteBook Fan Control

This repository contains scripts and configuration files to control the fan speed on HP EliteBook laptops, specifically tuned for the HP EliteBook 850 G5. The goal is to make the fans start at lower temperatures and run at higher speeds, especially during charging when the laptop gets hot.

Prerequisites

This solution uses nbfc-linux (NoteBook FanControl) which is a lightweight fan control service. You need to install it first:

# Arch Linux (using an AUR helper like paru)
paru -S nbfc-linux

Or see the nbfc repository

Files Included

  • smart-fan-control.sh: Main script that checks if laptop is plugged in and adjusts fan speed accordingly
  • fan-high.sh: Simple script to set fans to high speed (96%)
  • fan-auto.sh: Simple script to set fans to automatic control mode
  • nbfc-smart-control.service: Systemd service that runs the smart fan control script
  • nbfc-smart-control.timer: Systemd timer that runs the script every 5 minutes
  • nbfc-ac-event.rules: Udev rules to run the script when AC power is connected/disconnected
  • HP EliteBook 850 G5.json: NBFC configuration file for my laptop model

Installation

  1. Install nbfc-linux as shown in prerequisites
paru -S nbfc-linux
  1. Clone the repository
git clone https://github.com/ERFouX/hp-fan-control.git
  1. Go to the repository folder
cd hp-fan-control
  1. To grant executable access to the file, enter the following command:
chmod +x ./install.sh
  1. Run the installer
./install.sh

Manual Installation

Copy the configuration files to their proper locations:

# Create necessary directories
sudo mkdir -p /etc/nbfc/configs
sudo mkdir -p /etc/udev/rules.d

# Copy the configuration file
sudo cp "HP EliteBook 850 G5.json" /etc/nbfc/configs/

# Set the configuration
sudo nbfc config --set "HP EliteBook 850 G5"

# Copy scripts to bin directory
mkdir -p ~/bin
cp smart-fan-control.sh fan-high.sh fan-auto.sh ~/bin/
chmod +x ~/bin/smart-fan-control.sh ~/bin/fan-high.sh ~/bin/fan-auto.sh

# Copy systemd service and timer
sudo cp nbfc-smart-control.service nbfc-smart-control.timer /etc/systemd/system/

# Copy udev rules
sudo cp nbfc-ac-event.rules /etc/udev/rules.d/

# Enable and start services
sudo systemctl start nbfc_service
sudo systemctl enable nbfc_service
sudo systemctl enable nbfc-smart-control.service
sudo systemctl start nbfc-smart-control.timer
sudo systemctl enable nbfc-smart-control.timer

# Reload udev rules
sudo udevadm control --reload-rules

Usage

After installation, the system should automatically adjust the fan speed based on whether the laptop is plugged in or running on battery:

  • When plugged in: Fans run at 85% speed to keep the laptop cooler
  • When on battery: Fans are automatically controlled by nbfc based on temperature

‌ You can also manually control the fans:

# Set fans to high speed (96%)
~/bin/fan-high.sh

# Set fans to automatic control
~/bin/fan-auto.sh

# Run the smart control script manually
~/bin/smart-fan-control.sh

Checking Status

You can check the current fan status with:

nbfc status -a

To see if the timer is running:

systemctl list-timers | grep nbfc

Customization

This installer will create a folder in your home, you can edit it and change it to /usr/bin or something else

If you want to adjust the fan speeds, you can edit the smart-fan-control.sh script. The current setting uses 85% when plugged in, but you can change this to any value between 0 and 100.

Troubleshooting

If the fan control is not working:

  1. Check if nbfc service is running: systemctl status nbfc_service
  2. Check if the timer is running: systemctl status nbfc-smart-control.timer
  3. Run the script manually to see any errors: sudo ~/bin/smart-fan-control.sh
  4. Check the current AC status: cat /sys/class/power_supply/AC/online (1 means plugged in, 0 means on battery)

I would be happy if you open an issue if you see any problems.

Other Laptop Models

To use this on other laptop models, you will need to find or create an nbfc configuration file for your specific model. You can list available configs with:

nbfc config --list

And get your model name with:

nbfc get-model-name

support

You support me by giving this repository a star ⭐

About

This repository contains scripts and configuration files to control fan speed on my laptop.

Topics

Resources

License

Stars

Watchers

Forks

Languages