2020-04-23 10:38:21 +00:00
# mbpfan
2012-06-09 14:40:12 +00:00
2019-01-21 13:20:00 +00:00
[![Build Status ](https://travis-ci.org/dgraziotin/mbpfan.svg?branch=master )](https://travis-ci.org/dgraziotin/mbpfan)
2012-08-23 20:32:49 +00:00
This is an enhanced version of [Allan McRae mbpfan ](http://allanmcrae.com/2010/05/simple-macbook-pro-fan-daemon/ )
2012-06-09 14:25:28 +00:00
2017-08-10 19:46:56 +00:00
mbpfan is a daemon that uses input from coretemp module and sets the fan speed using the applesmc module.
2012-06-09 14:25:28 +00:00
This enhanced version assumes any number of processors and fans (max. 10).
2018-08-21 05:05:12 +00:00
* It only uses the temperatures from the processors as input.
* It requires coretemp and applesmc kernel modules to be loaded.
* It requires root use
* It daemonizes or stays in foreground
* Verbose mode for both syslog and stdout
* Users can configure it using the file /etc/mbpfan.conf
2012-06-09 14:25:28 +00:00
2017-08-10 19:46:56 +00:00
**Table Of Contents**
- [Supported GNU/Linux Distributions ](#supported-gnulinux-distributions )
2019-10-29 06:41:46 +00:00
- [Tested Mac Models ](#tested-mac-models )
2017-08-10 19:46:56 +00:00
- [Requirements ](#requirements )
- [Installation ](#installation )
- [Arch Linux ](#arch-linux )
2019-07-09 00:40:35 +00:00
- [CRUX Linux ](#crux-linux )
2019-04-28 06:13:45 +00:00
- [Debian ](#debian )
2019-10-04 22:14:14 +00:00
- [Fedora ](#fedora )
2017-08-10 19:46:56 +00:00
- [Gentoo ](#gentoo )
2019-10-04 22:14:14 +00:00
- [Solus ](#solus )
2019-04-28 06:13:45 +00:00
- [Ubuntu ](#ubuntu )
2017-08-10 19:46:56 +00:00
- [Generic Install Instructions (All Other Operating Systems) ](#generic-install-instructions-all-other-operating-systems )
- [Run Instructions ](#run-instructions )
- [Starting at boot ](#starting-at-boot )
- [Usage ](#usage )
2020-04-23 10:38:21 +00:00
- [References ](#references )
2017-08-10 19:46:56 +00:00
- [License ](#license )
2017-08-14 13:32:12 +00:00
- [Credits ](#credits )
2017-08-10 19:46:56 +00:00
## Supported GNU/Linux Distributions
2012-06-09 14:25:28 +00:00
2012-08-23 09:08:17 +00:00
We provide scripts to to load mbpfan daemon at system boot for many distros.
2012-10-20 15:18:30 +00:00
Please note that the support is provided by volunteers. mbpfan needs tests and bug reports.
2012-08-23 09:08:17 +00:00
Supported distributions:
- Ubuntu
- Debian
2013-10-13 16:18:17 +00:00
- Archlinux
2012-08-23 09:08:17 +00:00
- Fedora
- RedHat
- CentOS
- Gentoo
2017-03-27 15:44:34 +00:00
- Alpine
- Trisquel
2017-08-10 19:46:56 +00:00
- Solus
2019-10-29 06:41:46 +00:00
## Tested Mac Models
See https://github.com/linux-on-mac/mbpfan/wiki/Tested-Mac-Models .
2019-01-22 23:20:55 +00:00
2017-08-10 19:46:56 +00:00
## Requirements
2012-08-23 09:08:17 +00:00
Be sure to load the kernel modules **applesmc** and **coretemp** .
2017-08-10 19:46:56 +00:00
These modules are often automatically loaded when booting up GNU/Linux on a MacBook. If that is not the case, you should make sure to load them at system startup.
**How do I know if applesmc and coretemp are loaded?**
In most distributions, you can run the following command:
2018-08-21 05:05:12 +00:00
```bash
lsmod | grep -e applesmc -e coretemp
```
2017-08-10 19:46:56 +00:00
If you see `coretemp` and `applesmc` listed, you are all set.
**If you do not see `coretemp` and `applesmc` listed, you must load them.**
This is _usually_ achieved by inserting the following two lines in the file `/etc/modules`
2015-02-08 08:42:25 +00:00
```
coretemp
applesmc
```
2012-08-23 09:08:17 +00:00
2015-02-08 08:42:25 +00:00
Please check the relevant documentation of your GNU/Linux distribution.
2012-08-23 09:08:17 +00:00
2017-08-10 19:46:56 +00:00
## Installation
### Arch Linux
2013-10-13 16:27:52 +00:00
See [mbpfan-git at AUR ](https://aur.archlinux.org/packages/mbpfan-git/ ).
Otherwise, please refer to the Generic Instructions.
2019-07-09 00:40:35 +00:00
### CRUX Linux
Follow the instructions on [jolupalabs REPO ](https://github.com/jolupa/jolupalabs ) for installation.
2019-04-28 06:13:45 +00:00
### Debian
2013-10-13 16:27:52 +00:00
2019-04-28 06:13:45 +00:00
On Debian 10 or later install via:
2013-10-13 16:27:52 +00:00
2019-04-28 06:13:45 +00:00
```
sudo apt-get install mbpfan
```
2016-01-30 16:36:45 +00:00
2019-10-04 22:04:05 +00:00
### Fedora
2020-01-12 06:09:52 +00:00
On Fedora 30 or later:
2019-10-04 22:04:05 +00:00
```
sudo dnf install mbpfan
```
2017-08-10 19:46:56 +00:00
### Gentoo
2016-03-31 16:12:35 +00:00
2017-04-02 20:16:32 +00:00
Install the ```mbpfan``` package with:
2013-10-13 16:27:52 +00:00
2017-04-02 20:16:32 +00:00
sudo emerge -av app-laptop/mbpfan
2016-12-28 16:40:21 +00:00
2019-05-14 07:53:39 +00:00
### Solus
On Solus, install the package with:
```
sudo eopkg install mbpfan
```
then enable the service.
2019-04-28 06:13:45 +00:00
### Ubuntu
On Ubuntu 18.04 or later install via:
```
sudo apt-get install mbpfan
```
2017-08-10 19:46:56 +00:00
### Generic Install Instructions (All Other Operating Systems)
2012-06-09 14:25:28 +00:00
Compile with
2012-08-23 09:08:17 +00:00
make
2012-06-09 14:40:12 +00:00
2012-06-15 19:12:51 +00:00
Install with
2012-06-15 19:47:23 +00:00
2012-08-23 09:08:17 +00:00
sudo make install
2012-06-15 19:47:23 +00:00
2017-08-10 19:46:56 +00:00
It copies mbpfan to /usr/sbin, mbpfan.conf to /etc (and overwrites existing files),
2016-08-31 07:45:05 +00:00
README.md to /usr/share/doc/mbpfan, and mbpfan.8.gz to /usr/share/man/man8
2012-06-15 19:47:23 +00:00
2017-03-19 17:54:29 +00:00
If you would like to compile with Clang instead of GCC, simply set your system's
2017-03-27 17:03:02 +00:00
default compiler to be Clang. Tested with Clang 3.8 and 3.9. Tested with Clang
2017-08-10 19:46:56 +00:00
4.0 along with llvm-lld (The LLVM Linker).
2016-12-28 16:40:21 +00:00
2012-06-15 19:12:51 +00:00
2019-08-29 23:52:17 +00:00
Run The Tests (Optional)
------------------------
2020-05-19 14:06:27 +00:00
Users may run the tests after building the program. Please run the following command _from within the source directory_ .
2012-06-09 14:25:28 +00:00
2012-08-23 09:08:17 +00:00
sudo make tests
2012-08-22 13:05:52 +00:00
2019-08-29 23:52:17 +00:00
Note that this only works on MacBook and not desktop computers due to different environment expectations.
2012-06-15 19:12:51 +00:00
2017-08-10 19:46:56 +00:00
## Run Instructions
2012-06-15 19:47:23 +00:00
If not installed, run with
2012-08-23 09:08:17 +00:00
sudo bin/mbpfan
2012-06-09 14:40:12 +00:00
2012-06-15 19:47:23 +00:00
If installed, manually run with
2012-08-23 09:08:17 +00:00
sudo mbpfan
2012-06-15 19:47:23 +00:00
If installed and using the init file, run with (Ubuntu example)
2012-08-23 09:08:17 +00:00
sudo service mbpfan start
2012-06-15 19:47:23 +00:00
2012-08-22 13:05:52 +00:00
2017-08-10 19:46:56 +00:00
## Starting at boot
2012-08-22 13:53:07 +00:00
**Ubuntu**
2016-05-02 09:26:29 +00:00
2017-11-04 23:57:49 +00:00
For systemd based init systems (Ubuntu 16.04+), see the systemd section below.
2016-05-02 09:26:29 +00:00
2017-08-10 19:46:56 +00:00
For upstart based init systems (Ubuntu before 16.04), an example upstart job has been provided.
2016-05-02 09:26:29 +00:00
For using it, execute:
2012-08-23 09:08:17 +00:00
sudo cp mbpfan.upstart /etc/init/mbpfan.conf
sudo start mbpfan
2012-08-22 13:53:07 +00:00
**Debian**
2017-08-10 19:46:56 +00:00
An init file suitable for /lib/lsb/init-functions (Debian)
2012-08-22 13:05:52 +00:00
is located in the main folder of the source files, called mbpfan.init.debian
Rename it to mbpfan, give it execution permissions (chmod +x mbpfan)
and move it to /etc/init.d
2012-08-23 09:08:17 +00:00
Then, add it to the default runlevels with (as root):
sudo update-rc.d mbpfan defaults
2012-08-22 13:05:52 +00:00
2012-08-22 13:53:07 +00:00
**Redhat, CentOS, Fedora**
An init file suitable for /etc/rc.d/init.d/functions
2012-08-22 13:05:52 +00:00
(RHEL/CentOS & Fedora) is also located at the same place, this file is called
mbpfan.init.redhat. Also rename it to mbpfan, give it execution permissions
and move it to /etc/init.d
To add the script to the default runlevels, run the following as root:
2012-08-23 09:08:17 +00:00
chkconfig --level 2345 mbpfan on & & chkconfig --level 016 mbpfan off
**Gentoo**
To automatically run mbpfan at boot, run as root:
rc-update add mbpfan default
2012-08-22 13:05:52 +00:00
2012-08-22 13:53:07 +00:00
**systemd**
2012-08-22 13:05:52 +00:00
As a special bonus, a service file for systemd is also included. To use it,
2012-08-23 09:08:17 +00:00
execute the following (as root):
2015-10-22 12:33:30 +00:00
sudo cp mbpfan.service /etc/systemd/system/
2016-03-17 10:15:16 +00:00
sudo systemctl enable mbpfan.service
2012-08-23 09:08:17 +00:00
sudo systemctl daemon-reload
sudo systemctl start mbpfan.service
2012-08-22 13:53:07 +00:00
2022-04-02 14:42:31 +00:00
**dinit**
A [dinit ](https://github.com/davmac314/dinit ) service definition is also included. To use it, execute the following:
sudo cp mbpfan.dinit /etc/dinit.d/mbpfan
sudo dinitctl enable mbpfan
sudo dinitctl start mbpfan
2017-08-10 19:46:56 +00:00
## Usage
2012-07-03 08:39:30 +00:00
2012-08-23 09:08:17 +00:00
Usage: ./mbpfan OPTION(S)
-h Show the help screen
-f Run in foreground
-v Be (a lot) verbose
2012-07-03 08:39:30 +00:00
2020-04-23 10:38:21 +00:00
## References
* [mbpfan on Ask Ubuntu ](https://askubuntu.com/search?q=mbpfan+is%3Aquestion )
2012-06-09 14:40:12 +00:00
2017-08-10 19:46:56 +00:00
## License
2012-06-09 14:40:12 +00:00
GNU General Public License version 3
2012-06-09 14:25:28 +00:00
2019-11-01 19:23:34 +00:00
## Credits
2012-01-25 15:26:01 +00:00
2017-08-10 19:46:56 +00:00
**This Project Is Based On:**
2012-06-11 19:43:53 +00:00
* http://allanmcrae.com/2010/05/simple-macbook-pro-fan-daemon/
* http://allanmcrae.com/2011/08/mbp-fan-daemon-update/
* https://launchpad.net/macfanctld
2019-11-01 19:21:59 +00:00
* https://www.lobotomo.com/products/FanControl/
2017-08-14 13:32:12 +00:00
**This Project uses following library:**
2018-08-21 05:05:12 +00:00
* [ANSI C Application Settings Management ](http://pokristensson.com/settings.html ) by Per Ola Kristensson.