Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows support #57

Open
wants to merge 44 commits into
base: packaging/windows
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
2047e54
Add windows installation #30
leopoldhub Jul 6, 2024
0bd5b54
fix installation after test with real hardware
leopoldhub Jul 6, 2024
2b5ef6b
fixing typos
leopoldhub Jul 6, 2024
b7db20a
Merge branch 'TamtamHero:main' into dev-windows
leopoldhub Aug 3, 2024
cab888b
working windows version!
leopoldhub Aug 4, 2024
fa5b675
Merge branch 'TamtamHero:main' into dev-windows
leopoldhub Aug 9, 2024
a774785
README.md documentation update
leopoldhub Aug 9, 2024
0616bf8
change log format on fatal crash
leopoldhub Aug 9, 2024
46e19cb
fix badges links
leopoldhub Aug 9, 2024
0dc997c
README.md update with windows documentation
leopoldhub Aug 9, 2024
3fe74bb
removing linux specific files and socket controllers
leopoldhub Aug 9, 2024
624fed4
woops, putting the LICENSE back...
leopoldhub Aug 9, 2024
cf3e36a
remove linux specific part from the README.md
leopoldhub Aug 9, 2024
480f867
fix error on main rebase, and make the windows name pipe (socket) ava…
leopoldhub Aug 10, 2024
06d69c9
fix mishaps in the documentation
leopoldhub Aug 10, 2024
2ef31c1
README.md documentation update (#65)
leopoldhub Aug 13, 2024
871566f
Command arguments refactoring Pt.1 (#66)
leopoldhub Aug 13, 2024
64d62b4
Merge remote-tracking branch 'refs/remotes/real/main' into dev-windows
leopoldhub Aug 13, 2024
b4f87b6
finishing touches (#67)
leopoldhub Aug 13, 2024
9b63ded
Merge remote-tracking branch 'refs/remotes/real/main' into dev-windows
leopoldhub Aug 13, 2024
00cfec4
adding back stacktrace on fatal fail
leopoldhub Aug 13, 2024
1196999
removing unused dependencies
leopoldhub Aug 13, 2024
3b1779d
update windows "one-line" download command
leopoldhub Aug 13, 2024
e4d6441
windows batch are a bit capricious...
leopoldhub Aug 13, 2024
7f17443
small fixes after merge
leopoldhub Aug 13, 2024
80a239d
add no battery mode for mainboards without battery (#69)
saizo80 Aug 18, 2024
da6e8d2
Merge remote-tracking branch 'refs/remotes/real/main' into dev-windows
leopoldhub Aug 18, 2024
cc65f26
adding ectool sub-dependency to documentation (#70)
leopoldhub Aug 18, 2024
88590e3
typo "tempurature" => "temperature" (#71)
leopoldhub Aug 18, 2024
6d2d3de
typo "tempurature" => "temperature" (#72)
leopoldhub Aug 18, 2024
6681c6b
add "/no-battery-sensors" installation argument
leopoldhub Aug 18, 2024
c8223fd
Merge remote-tracking branch 'refs/remotes/real/main' into dev-windows
leopoldhub Aug 18, 2024
a961cfa
adding service pause on sleep and resume on wake
leopoldhub Aug 21, 2024
23d53ed
adding service pause on sleep and resume on wake
leopoldhub Aug 21, 2024
db6fb77
Merge remote-tracking branch 'origin/dev-windows' into dev-windows
leopoldhub Aug 21, 2024
ec9a9ae
Add ToC + link to NixOS Documentation (#75)
Svenum Aug 24, 2024
fe98b44
add --no-sudo option (#76)
Svenum Aug 24, 2024
4a8a3a0
Add choice to print fan speed percentage (#78)
Speenah Aug 24, 2024
2a9828f
add missing no_sudo check (#79)
Svenum Aug 25, 2024
b6a70a9
fix typo (#84)
leopoldhub Nov 1, 2024
d34757b
Merge branch 'main' into dev-windows
leopoldhub Nov 1, 2024
2e03bc2
updated TOC and opted for an autogenerated one (will be easier to kee…
leopoldhub Nov 1, 2024
278d0ff
Merge branch 'main' into dev-windows
leopoldhub Nov 1, 2024
4ba02b2
merged main
leopoldhub Nov 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report---packaging-windows.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
name: Bug report | packaging/windows
about: Report a bug involving the windows packaging
title: "[BUG] [packaging/windows]"
labels: bug, packaging/windows
assignees: 'leopoldhub'

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Error message**
```txt
If applicable, add the full error message.
```

**Environment (please complete the following information):**
- OS: [e.g. Windows 11]
- Version [e.g. commit 176d34b]
- Configuration file [config.json]

**Additional context**
Add any other context about the problem here.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Nix Build dir
/result

### Intellij template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
Expand Down
161 changes: 95 additions & 66 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,97 +1,126 @@
# fw-fanctrl

This is a simple Python service for Linux that drives Framework Laptop's fan(s) speed according to a configurable speed/temp curve.
Its default configuration targets very silent fan operation, but it's easy to configure it for a different comfort/performance trade-off.
Its possible to specify two separate fan curves depending on whether the Laptop is charging/discharging.
Under the hood, it uses [ectool](https://gitlab.howett.net/DHowett/ectool) to change parameters in Framework's embedded controller (EC).
[![Static Badge](https://img.shields.io/badge/Windows-0078D6?style=flat&label=Platform&link=https%3A%2F%2Fgithub.com%2FTamtamHero%2Ffw-fanctrl%2Ftree%2Fpackaging%2Fwindows)](https://github.com/TamtamHero/fw-fanctrl/tree/packaging/windows)

It is compatible with all kinds of 13" and 16" models, both AMD/Intel CPUs, with or without a discrete GPU.
[![Static Badge](https://img.shields.io/badge/Python__3.12-FFDE57?style=flat&label=Requirement&link=https%3A%2F%2Fwww.python.org%2Fdownloads)](https://www.python.org/downloads)

## Additional platforms:

[![Static Badge](https://img.shields.io/badge/Linux%2FGlobal-FCC624?style=flat&logo=linux&logoColor=FFFFFF&label=Platform&link=https%3A%2F%2Fgithub.com%2FTamtamHero%2Ffw-fanctrl%2Ftree%2Fmain)](https://github.com/TamtamHero/fw-fanctrl/tree/main)

[![Static Badge](https://img.shields.io/badge/NixOS-5277C3?style=flat&logo=nixos&logoColor=FFFFFF&label=Platform&link=https%3A%2F%2Fgithub.com%2FTamtamHero%2Ffw-fanctrl%2Ftree%2Fpackaging%2Fnix)](https://github.com/TamtamHero/fw-fanctrl/tree/packaging/nix/doc/nix-flake.md)

## Description

Fw-fanctrl is a simple Python CLI service that controls Framework Laptop's fan(s)
speed according to a configurable speed/temperature curve.

Its default strategy aims for very quiet fan operation, but you can choose amongst the other provided strategies, or
easily configure your own for a different comfort/performance trade-off.

It also is possible to assign separate strategies depending on whether the laptop is charging or discharging.

Under the hood, it uses [ectool](https://gitlab.howett.net/DHowett/ectool)
to change parameters in Framework's embedded controller (EC).

It is compatible with all 13" and 16" models, both AMD/Intel CPUs, with or without a discrete GPU.

If the service is paused or stopped, the fans will revert to their default behaviour.

# Install
## Table of Content

## Dependencies
<!-- TOC -->
* [fw-fanctrl](#fw-fanctrl)
* [Additional platforms:](#additional-platforms)
* [Description](#description)
* [Table of Content](#table-of-content)
* [Documentation](#documentation)
* [Installation](#installation)
* [Other Platforms](#other-platforms)
* [Requirements](#requirements)
* [Dependencies](#dependencies)
* [Instructions](#instructions)
* [Update](#update)
* [Uninstall](#uninstall)
<!-- TOC -->

To communicate with the embedded controller the `ectool` is required.
You can either let the script download it from the [gitlab repository](https://gitlab.howett.net/DHowett/ectool) artifacts,
or disable its installation (`--no-ectool`) and install your own.
## Documentation

You also need to disable secure boot of your device for `ectool` to work (more details about why [here](https://www.howett.net/posts/2021-12-framework-ec/#using-fw-ectool))
More documentation could be found [here](./doc/README.md).

Then run:
```bash
sudo ./install.sh
```
## Installation

This bash script will to create and activate a service that runs this repo's main script, `fanctrl.py`.
It will copy `fanctrl.py` (to an executable file `fw-fanctrl`), download the ectool to `[dest-dir(/)]/bin` and create a config file
in `[dest-dir(/)][sysconf-dir(/etc)]/fw-fanctrl/config.json`
### Other Platforms

this script also includes options to:
- specify an installation destination directory (`--dest-dir <installation destination directory (defaults to /)>`).
- specify an installation prefix directory (`--prefix-dir <installation prefix directory (defaults to /usr)>`).
- specify a default configuration directory (`--sysconf-dir <system configuration destination directory (defaults to /etc)>`).
- disable ectool installation and service activation (`--no-ectool`)
- disable post-install process (`--no-post-install`)
- disable pre-uninstall process (`--no-pre-uninstall`)
| name | branch | documentation |
|--------------|------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------|
| Linux/Global | [main](https://github.com/TamtamHero/fw-fanctrl/tree/main) | [main/doc](https://github.com/TamtamHero/fw-fanctrl/tree/main/doc/README.md) |
| NixOS | [packaging/nix](https://github.com/TamtamHero/fw-fanctrl/tree/packaging/nix) | [packaging/nix/doc/nix-flake](https://github.com/TamtamHero/fw-fanctrl/tree/packaging/nix/doc/nix-flake.md) |

# Update
### Requirements

To install an update, you can pull the latest commit on the `main` branch of this repository, and run the install script again.
| name | version | url |
|--------|---------|----------------------------------------------------------------------|
| Python | 3.12.x | [https://www.python.org/downloads](https://www.python.org/downloads) |

# Uninstall
```bash
sudo ./install.sh --remove
```
### Dependencies

# Configuration
Dependencies are downloaded and installed automatically.

There is a single `config.json` file located at `[dest-dir(/)][sysconf-dir(/etc)]/fw-fanctrl/config.json`.
| name | version | url |
|----------------|--------------|------------------------------------------------------------------------------------------------------|
| DHowett@crosec | v0.0.2 | [https://github.com/DHowett/FrameworkWindowsUtils](https://github.com/DHowett/FrameworkWindowsUtils) |
| DHowett@ectool | artifact#904 | [https://gitlab.howett.net/DHowett/ectool](https://gitlab.howett.net/DHowett/ectool) |
| nssm | 2.24 | [https://nssm.cc](https://nssm.cc) |

(You will need to reload the configuration with)
```bash
fw-fanctrl --reload
```
### Instructions

Please note that the windows version of this service uses an unsigned
experimental [crosec](https://github.com/DHowett/FrameworkWindowsUtils) driver that may be unstable.
We are not responsible for any damage or data loss that this may cause.

It contains different strategies, ranked from the most silent to the noisiest. It is possible to specify two different strategies for charging/discharging allowing for different optimization goals.
On discharging one could have fan curve optimized for low fan speeds in order to save power while accepting a bit more heat.
On charging one could have a fan curve that focuses on keeping the CPU from throttling and the system cool, at the expense of fan noise.
You can add new strategies, and if you think you have one that deserves to be shared, feel free to make a PR to this repo :)
First, make sure that you have disabled secure boot in your BIOS/UEFI settings.
(more details on why [here](https://www.howett.net/posts/2021-12-framework-ec/#using-fw-ectool))

```
============================================================================
IF YOU HAVE BITLOCKER ENABLED, YOU WILL NEED YOUR RECOVERY CODE ON BOOT !!!!
PLEASE MAKE A BACKUP OF YOUR BITLOCKER RECOVERY KEY BEFORE YOU DO ANYTHING !
YOU GET LOCKED OUT OF YOUR COMPUTER IF YOU ARE NOT CAREFUL ENOUGH !
============================================================================
```

Strategies can be configured with the following parameters:
[Download the repo](https://github.com/TamtamHero/fw-fanctrl/archive/refs/heads/packaging/windows.zip) and extract it
manually, or download/clone it with the appropriate tools:

- **SpeedCurve**:
```shell
git clone --branch "packaging/windows" "https://github.com/TamtamHero/fw-fanctrl.git"
```

This is the curve points for `f(temperature) = fan speed`
```shell
curl -L "https://github.com/TamtamHero/fw-fanctrl/archive/refs/heads/packaging/windows.zip" -o "./fw-fanctrl.zip" && tar -xf "./fw-fanctrl.zip" && del "./fw-fanctrl.zip"
```

`fw-fanctrl` measures the CPU temperature, compute a moving average of it, and then find an appropriate `fan speed` value by interpolation on the curve.
Then run the installation script with administrator privileges (by double clicking it, or with the following command)

- **FanSpeedUpdateFrequency**:
```shell
install.bat
```

Time interval between every update to the fan's speed. `fw-fanctrl` measures temperature every second and add it to its moving average, but the actual update to fan speed is controlled using this configuration. This is for comfort, otherwise the speed is changed too often and it is noticeable and annoying, especially at low speed.
For a more reactive fan, you can lower this setting. **Defaults to 5 seconds.**
You can add a number of arguments to the installation command to suit your needs

- **MovingAverageInterval**:
| argument | description |
|-----------------------|----------------------------------------------|
| `/no-battery-sensors` | disable checking battery temperature sensors |

Number of seconds on which the moving average of temperature is computed. Increase it, and the fan speed will change more gradually. Lower it, and it will gain in reactivity. **Defaults to 20 seconds.**
## Update

## Charging/Discharging strategies
To update, you can download or pull the appropriate branch from this repository, and run the installation script again.

The strategy active by default is the one specified in the `defaultStrategy` entry. Optionally a separate strategy only active during discharge can be defined, using the `strategyOnDischarging` entry. By default no extra strategy for discharging is provided, the default strategy is active during all times.
## Uninstall

# Commands
To uninstall, run the uninstallation script `uninstall.bat` (by double clicking it, or with the following command)

| Option | Context | Description |
|-----------------------------|-----------------|-------------------------------------------------------------------------------|
| \<strategy> | run & configure | the name of the strategy to use |
| --run | run | run the service |
| --config | run | specify the configuration path |
| --no-log | run | disable state logging |
| --query, -q | configure | print the current strategy name |
| --list-strategies | configure | print the available strategies |
| --reload, -r | configure | reload the configuration file |
| --pause | configure | temporarily disable the service and reset the fans to their default behaviour |
| --resume | configure | resume the service |
| --hardware-controller, --hc | run | select the hardware controller. choices: ectool |
| --socket-controller, --sc | run & configure | select the socket controller. choices: unix |
```shell
uninstall.bat
```
7 changes: 7 additions & 0 deletions doc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Table of Content

- [Windows Installation](../README.md#installation)
- [Linux/Global](https://github.com/TamtamHero/fw-fanctrl/tree/main#installation)
- [NixOS Flake](https://github.com/TamtamHero/fw-fanctrl/tree/packaging/nix/doc/nix-flake.md)
- [Commands](./commands.md)
- [Configuration](./configuration.md)
82 changes: 82 additions & 0 deletions doc/commands.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Table of Content

<!-- TOC -->
* [Table of Content](#table-of-content)
* [Commands](#commands)
* [run](#run)
* [use](#use)
* [reset](#reset)
* [reload](#reload)
* [pause](#pause)
* [resume](#resume)
* [print](#print)
<!-- TOC -->

# Commands

Here is a list of commands and options used to interact with the service.

the base of all commands is the following

```shell
fw-fanctrl [commands and options]
```

First, the global options

| Option | Optional | Choices | Default | Description |
|---------------------------|----------|---------|---------|--------------------------------------------------------------------------------|
| --socket-controller, --sc | yes | win32 | win32 | the socket controller to use for communication between the cli and the service |

## run

run the service manually

If you have installed it correctly, the systemd `fw-fanctrl.service` service will do this for you, so you probably will
never need those.

| Option | Optional | Choices | Default | Description |
|-----------------------------|----------|----------------|----------------------|-----------------------------------------------------------------------------------|
| \<strategy> | yes | | the default strategy | the name of the strategy to use |
| --config | yes | \[CONFIG_PATH] | | the configuration file path |
| --silent, -s | yes | | | disable printing speed/temp status to stdout |
| --hardware-controller, --hc | yes | ectool | ectool | the hardware controller to use for fetching and setting the temp and fan(s) speed |
| --no-battery-sensors | yes | | | disable checking battery temperature sensors (for mainboards without batteries) |

## use

change the current strategy

| Option | Optional | Description |
|-------------|----------|---------------------------------|
| \<strategy> | no | the name of the strategy to use |

## reset

reset to the default strategy

## reload

reload the configuration file

## pause

pause the service

## resume

resume the service

## print

print the selected information

| Option | Optional | Choices | Default | Description |
|--------------------|----------|----------------------|---------|------------------------|
| \<print_selection> | yes | current, list, speed | current | what should be printed |

| Choice | Description |
|---------|----------------------------------|
| current | The current strategy being used |
| list | List available strategies |
| speed | The current fan speed percentage |
Loading