This script runs at system startup/login and checks if a cooling fan is present on a Linux system.
If no fan is detected during startup, it shows a graphical prompt asking the user whether to shut down the system.
- Detects fan presence via:
- hwmon sensors
/boot/firmware/config.txtoverlay (dtoverlay=gpio-fan)dmesglogs- manually labeled GPIO pins
- If no fan is detected, shows a GUI confirmation dialog (via Zenity)
- Logs to
/var/log/fan_check.log
- Any Linux distribution with a graphical environment (X11 or Wayland)
zenityinstalled (for the GUI window)shutdowncommand available
-
Install Zenity:
sudo apt install zenity
-
Copy the script to a permanent location:
sudo cp check_fan.sh /usr/local/bin/ sudo chmod +x /usr/local/bin/check_fan.sh
-
To run on login (autostart), copy the desktop entry:
mkdir -p ~/.config/autostart cp fan-check.desktop ~/.config/autostart/
You can run the script manually at any time:
/usr/local/bin/check_fan.shCheck the logs after executing.
All events and decisions are logged to:
/var/log/fan_check.log
MIT License