Skip to content

Commit

Permalink
Rebase Packaging/nix (TamtamHero#77)
Browse files Browse the repository at this point in the history
* Adding @Svenum as an assignee to nix-related issues (TamtamHero#43)

* Fixing adding @Svenum as an assignee to nix-related issues (TamtamHero#44)

(non contributors cannot be assigned to issues)

* Reload will report if config couldn't be parsed and the service keeps running. (TamtamHero#46)

Authored-by: Nina Alexandra Klama <[email protected]>

* Removing binary blobs from the project (TamtamHero#51)

* removing binary blobs from the project.
we now fetch the ectool from the gitlab artifacts and confirm the checksum.

* remove bin references from README.md

* extracting $TEMP_FOLDER from installEctool

* Fix README spelling/grammer, fix "FrameWork" capitalization in service description (TamtamHero#52)

* Review README spelling/grammar

* Fix "FrameWork" capitalization in service

* Clarify behaviour on service stop or pause (TamtamHero#53) (TamtamHero#55)

* Separating FanController into different subclasses to allow HardwareController and SocketController diversity. 2 (Repost of TamtamHero#50) (TamtamHero#58)

* separating `FanController` into different subclasses to allow `HardwareController` and `SocketController` diversity

* adding the new arguments into the README.md

* fixing an indentation error causing `--strategy <strategy>` not to work (the simple `<strategy>` still worked)

* fixing missing print for command execution (TamtamHero#63)

* forcing utf-8 encoding for socket messages and usage of stopServerSocket method instead of manual closing, as well as updating error detection pattern (TamtamHero#64)

* README.md documentation update (TamtamHero#65)

* forcing utf-8 encoding for socket messages and usage of stopServerSocket method instead of manual closing, as well as updating error detection pattern

* README.md documentation update

* change log format on fatal crash

* fix badges links

* adding windows platform badge and issue template

* fix `:` instead of `=`

* disabling part of the README.md while waiting for merge

* Command arguments refactoring Pt.1 (TamtamHero#66)

* forcing utf-8 encoding for socket messages and usage of stopServerSocket method instead of manual closing, as well as updating error detection pattern

* README.md documentation update

* change log format on fatal crash

* fix badges links

* adding windows platform badge and issue template

* fix `:` instead of `=`

* first part of the command argument refactoring.

the old argument format is deprecated but still usable.

improved feedback when executing commands.

TamtamHero#31

* trim blank lines in README.md

* finishing touches (TamtamHero#67)

* add no battery mode for mainboards without battery (TamtamHero#69)

* add configuration for no battery mode in hardware controller

* fix wrong line getting noBatteryMode

* dynamically fetching battery sensor on init/reload

* add --no-battery flag for install

* update readme with --no-battery flag

* rework no battery config to come from service args

* change sensors to be ectool specific

- reword the argument to be more clear about battery sensors
- move `noBatteryMode` and `nonBatterySensors` to EctoolHardwareController
- update `getNonBatterySensors` to be able to handle more than one sensor
- update installer and readme accordingly

* update grep command for checking existing `--no-battery-sensors`

* combine getTemperature functions to one

* add documentation for run option `--no-battery-sensors`

* rename variable `NO_BATTERY` to `NO_BATTERY_SENSOR`

* update the installer to use existing placeholder format

* rename noBatterySensorMode variables and functions for clarity

* rename placeholder to `NO_BATTERY_SENSOR_OPTION` for clarity

* update comments in installer to reflect new argument name

* adding ectool sub-dependency to documentation (TamtamHero#70)

* typo "tempurature" => "temperature" (TamtamHero#71)

typo "tempurature" => "temperature"

* typo "tempurature" => "temperature" (TamtamHero#72)

typo "tempurature" => "temperature"

* Add ToC + link to NixOS Documentation (TamtamHero#75)

* add doc folder

* update nix link

* add toc

* add link

* add missin #

* add doc

* fix link

* add new line under titles

* add --no-sudo option (TamtamHero#76)

* Add choice to print fan speed percentage (TamtamHero#78)

* Add option to print current speed percentage

* Update README.md

* Update commands.md

* Add print choice descriptions to help text

* add missing no_sudo check (TamtamHero#79)

* Add NixOS Flake (TamtamHero#26)

* initial

* update gitignore

* update inputs

* add fw-ectool dependencie

* add module

* fix tabs

* fix package

* fix typo

* fix service

* fix type

* add options

* fix service

* fix build inputs

* add Readme + add suspend script

* remove unneeded };

* fix pkgs.writeShellScript

* remvoe \

* try

* add self

* fix module

* update package

* fix package

* use sleep script

* add config options

* fix typo

* fix typo

* add defaults

* fix type

* add prettyier

* remove beautifyer

* udpate readme

* update installer script

* add missing path

* Update README.md

Co-authored-by: Thomas Eizinger <[email protected]>

* Update flake.nix

Co-authored-by: Thomas Eizinger <[email protected]>

* Update nix/module.nix

Co-authored-by: Thomas Eizinger <[email protected]>

* add descriptions

* fix uninstall

* update readme

* add description

* remove requiremetns.txt + add github actions

* update action

* rename workflow test

* fix service

* try

* try

* Update README.md

* Update README.md

* chagne flake description

* fix suspend script

* fix script

* fix path

* fix install.sh

* fix --no-sudo

* add --no-sudo to other scripts

* fix check

* add option check

* add missing "

* Rename nix action

---------

Co-authored-by: Thomas Eizinger <[email protected]>

* Update branch to main branch (TamtamHero#54)

* Adding @Svenum as an assignee to nix-related issues (TamtamHero#43)

* Fixing adding @Svenum as an assignee to nix-related issues (TamtamHero#44)

(non contributors cannot be assigned to issues)

* Reload will report if config couldn't be parsed and the service keeps running. (TamtamHero#46)

Authored-by: Nina Alexandra Klama <[email protected]>

* Removing binary blobs from the project (TamtamHero#51)

* removing binary blobs from the project.
we now fetch the ectool from the gitlab artifacts and confirm the checksum.

* remove bin references from README.md

* extracting $TEMP_FOLDER from installEctool

* Fix README spelling/grammer, fix "FrameWork" capitalization in service description (TamtamHero#52)

* Review README spelling/grammar

* Fix "FrameWork" capitalization in service

* use ectool form nixpkgs

* update flake

* remove old deps

* remove duplicated pkgs

---------

Co-authored-by: Léopold Hubert <[email protected]>
Co-authored-by: Nina Alexandra Klama <[email protected]>
Co-authored-by: DeflateAwning <[email protected]>

* Update to main branch + switch to fw-ectool (TamtamHero#61)

* Adding @Svenum as an assignee to nix-related issues (TamtamHero#43)

* Fixing adding @Svenum as an assignee to nix-related issues (TamtamHero#44)

(non contributors cannot be assigned to issues)

* Reload will report if config couldn't be parsed and the service keeps running. (TamtamHero#46)

Authored-by: Nina Alexandra Klama <[email protected]>

* Removing binary blobs from the project (TamtamHero#51)

* removing binary blobs from the project.
we now fetch the ectool from the gitlab artifacts and confirm the checksum.

* remove bin references from README.md

* extracting $TEMP_FOLDER from installEctool

* Fix README spelling/grammer, fix "FrameWork" capitalization in service description (TamtamHero#52)

* Review README spelling/grammar

* Fix "FrameWork" capitalization in service

* Clarify behaviour on service stop or pause (TamtamHero#53) (TamtamHero#55)

* Separating FanController into different subclasses to allow HardwareController and SocketController diversity. 2 (Repost of TamtamHero#50) (TamtamHero#58)

* separating `FanController` into different subclasses to allow `HardwareController` and `SocketController` diversity

* adding the new arguments into the README.md

* fixing an indentation error causing `--strategy <strategy>` not to work (the simple `<strategy>` still worked)

* add fw-ectool in module

* fixing missing print for command execution (TamtamHero#63)

---------

Co-authored-by: Léopold Hubert <[email protected]>
Co-authored-by: Nina Alexandra Klama <[email protected]>
Co-authored-by: DeflateAwning <[email protected]>

* add doc + .gitignore

* Add NixOS Flake (TamtamHero#26)

* initial

* update gitignore

* update inputs

* add fw-ectool dependencie

* add module

* fix tabs

* fix package

* fix typo

* fix service

* fix type

* add options

* fix service

* fix build inputs

* add Readme + add suspend script

* remove unneeded };

* fix pkgs.writeShellScript

* remvoe \

* try

* add self

* fix module

* update package

* fix package

* use sleep script

* add config options

* fix typo

* fix typo

* add defaults

* fix type

* add prettyier

* remove beautifyer

* udpate readme

* update installer script

* add missing path

* Update README.md

Co-authored-by: Thomas Eizinger <[email protected]>

* Update flake.nix

Co-authored-by: Thomas Eizinger <[email protected]>

* Update nix/module.nix

Co-authored-by: Thomas Eizinger <[email protected]>

* add descriptions

* fix uninstall

* update readme

* add description

* remove requiremetns.txt + add github actions

* update action

* rename workflow test

* fix service

* try

* try

* Update README.md

* Update README.md

* chagne flake description

* fix suspend script

* fix script

* fix path

* fix install.sh

* fix --no-sudo

* add --no-sudo to other scripts

* fix check

* add option check

* add missing "

* Rename nix action

---------

Co-authored-by: Thomas Eizinger <[email protected]>

* Update branch to main branch (TamtamHero#54)

* Adding @Svenum as an assignee to nix-related issues (TamtamHero#43)

* Fixing adding @Svenum as an assignee to nix-related issues (TamtamHero#44)

(non contributors cannot be assigned to issues)

* Reload will report if config couldn't be parsed and the service keeps running. (TamtamHero#46)

Authored-by: Nina Alexandra Klama <[email protected]>

* Removing binary blobs from the project (TamtamHero#51)

* removing binary blobs from the project.
we now fetch the ectool from the gitlab artifacts and confirm the checksum.

* remove bin references from README.md

* extracting $TEMP_FOLDER from installEctool

* Fix README spelling/grammer, fix "FrameWork" capitalization in service description (TamtamHero#52)

* Review README spelling/grammar

* Fix "FrameWork" capitalization in service

* use ectool form nixpkgs

* update flake

* remove old deps

* remove duplicated pkgs

---------

Co-authored-by: Léopold Hubert <[email protected]>
Co-authored-by: Nina Alexandra Klama <[email protected]>
Co-authored-by: DeflateAwning <[email protected]>

* Update to main branch + switch to fw-ectool (TamtamHero#61)

* Adding @Svenum as an assignee to nix-related issues (TamtamHero#43)

* Fixing adding @Svenum as an assignee to nix-related issues (TamtamHero#44)

(non contributors cannot be assigned to issues)

* Reload will report if config couldn't be parsed and the service keeps running. (TamtamHero#46)

Authored-by: Nina Alexandra Klama <[email protected]>

* Removing binary blobs from the project (TamtamHero#51)

* removing binary blobs from the project.
we now fetch the ectool from the gitlab artifacts and confirm the checksum.

* remove bin references from README.md

* extracting $TEMP_FOLDER from installEctool

* Fix README spelling/grammer, fix "FrameWork" capitalization in service description (TamtamHero#52)

* Review README spelling/grammar

* Fix "FrameWork" capitalization in service

* Clarify behaviour on service stop or pause (TamtamHero#53) (TamtamHero#55)

* Separating FanController into different subclasses to allow HardwareController and SocketController diversity. 2 (Repost of TamtamHero#50) (TamtamHero#58)

* separating `FanController` into different subclasses to allow `HardwareController` and `SocketController` diversity

* adding the new arguments into the README.md

* fixing an indentation error causing `--strategy <strategy>` not to work (the simple `<strategy>` still worked)

* add fw-ectool in module

* fixing missing print for command execution (TamtamHero#63)

---------

Co-authored-by: Léopold Hubert <[email protected]>
Co-authored-by: Nina Alexandra Klama <[email protected]>
Co-authored-by: DeflateAwning <[email protected]>

---------

Co-authored-by: Léopold Hubert <[email protected]>
Co-authored-by: Nina Alexandra Klama <[email protected]>
Co-authored-by: DeflateAwning <[email protected]>
Co-authored-by: Oli Thornton <[email protected]>
Co-authored-by: Ryan <[email protected]>
Co-authored-by: Thomas Eizinger <[email protected]>
  • Loading branch information
7 people authored Aug 25, 2024
1 parent c79c43e commit c5ec1c0
Show file tree
Hide file tree
Showing 12 changed files with 683 additions and 182 deletions.
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.
178 changes: 89 additions & 89 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,111 +1,111 @@
# 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/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/no%20binary%20blobs-30363D?style=flat&logo=GitHub-Sponsors&logoColor=4dff61)

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/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
For NixOS this repo contains an Flake. You could add it to your config like this:

```nix
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
fw-fanctrl = {
url = "github:TamtamHero/fw-fanctrl/packaging/nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {nixpkgs, fw-fanctrl}: {
nixosConfigurations.foo = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
fw-fanctrl.nixosModules.default
configuration.nix
];
};
}
}
```
and then add in your *configuration.nix*:
```nix
# Enable fw-fanctrl
programs.fw-fanctrl.enable = true;
# Add a custom config
programs.fw-fanctrl.config = {
defaultStrategy = "lazy";
strategies = {
"lazy" = {
fanSpeedUpdateFrequency = 5;
movingAverageInterval = 30;
speedCurve = [
{ temp = 0; speed = 15; }
{ temp = 50; speed = 15; }
{ temp = 65; speed = 25; }
{ temp = 70; speed = 35; }
{ temp = 75; speed = 50; }
{ temp = 85; speed = 100; }
];
};
};
};
# Add a custom config from an existing JSON file
programs.fw-fanctrl.config = builtins.fromJSON (builtins.readFile ./config.json)
# Or just change the default strategy form the default config
programs.fw-fanctrl.config.defaultStrategy = "medium";
```
## Table of Content

Non NixOS install is described [here](https://github.com/TamtamHero/fw-fanctrl/blob/main/README.md#Install)
- [Documentation](#documentation)
- [Installation](#installation)
* [Requirements](#requirements)
* [Dependencies](#dependencies)
* [Instructions](#instructions)
- [Update](#update)
- [Uninstall](#uninstall)

## Documentation

# Configuration
More documentation could be found [here](./doc/README.md).

The default config 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 :)
## Installation

Strategies can be configured with the following parameters:
### Other Platforms
| name | branch | documentation |
|-------|---------------|---------------|
| 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) |

- **SpeedCurve**:
### Requirements

This is the curve points for `f(temperature) = fan speeds`
| name | version | url |
|--------|---------|----------------------------------------------------------------------|
| Python | 3.12.x | [https://www.python.org/downloads](https://www.python.org/downloads) |

`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.
### Dependencies

- **FanSpeedUpdateFrequency**:
Dependencies are downloaded and installed automatically, but can be excluded from the installation script if you wish to
do this manually.

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.**
| name | version | url | sub-dependencies | exclusion argument |
|----------------|-----------|--------------------------------------------------------------------------------------|------------------|--------------------|
| DHowett@ectool | build#899 | [https://gitlab.howett.net/DHowett/ectool](https://gitlab.howett.net/DHowett/ectool) | libftdi | `--no-ectool` |

- **MovingAverageInterval**:
### Instructions

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.**
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))

## Charging/Discharging strategies
[Download the repo](https://github.com/TamtamHero/fw-fanctrl/archive/refs/heads/main.zip) and extract it manually, or
download/clone it with the appropriate tools:

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.
```shell
git clone "https://github.com/TamtamHero/fw-fanctrl.git"
```

# Commands
```shell
curl -L "https://github.com/TamtamHero/fw-fanctrl/archive/refs/heads/main.zip" -o "./fw-fanctrl.zip" && unzip "./fw-fanctrl.zip" -d "./fw-fanctrl" && rm -rf "./fw-fanctrl.zip"
```

Then run the installation script with administrator privileges

```bash
sudo ./install.sh
```

You can add a number of arguments to the installation command to suit your needs

| argument | description |
|---------------------------------------------------------------------------------|----------------------------------------------------|
| `--dest-dir <installation destination directory (defaults to /)>` | specify an installation destination directory |
| `--prefix-dir <installation prefix directory (defaults to /usr)>` | specify an installation prefix directory |
| `--sysconf-dir <system configuration destination directory (defaults to /etc)>` | specify a default configuration directory |
| `--no-ectool` | disable ectool installation and service activation |
| `--no-post-install` | disable post-install process |
| `--no-pre-uninstall` | disable pre-uninstall process |
| `--no-battery-sensors` | disable checking battery temperature sensors |

## Update

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

## Uninstall

To uninstall, run the installation script with the `--remove` argument, as well as other
corresponding [arguments if necessary](#instructions)

```bash
sudo ./install.sh --remove
```

| 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 |
6 changes: 6 additions & 0 deletions doc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Table of Content

- [Default Installation](../README.md#installation)
- [NixOS Flake](https://github.com/TamtamHero/fw-fanctrl/tree/packaging/nix/doc/nix-flake.md)
- [Commands](./commands.md)
- [Configuration](./configuration.md)
68 changes: 68 additions & 0 deletions doc/commands.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# 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 | unix | unix | 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

0 comments on commit c5ec1c0

Please sign in to comment.