From a1bfd3df419088c74770e6cc69654dede49c1069 Mon Sep 17 00:00:00 2001 From: Casu Al Snek Date: Fri, 20 Feb 2026 19:37:50 +0545 Subject: [PATCH 1/8] chore: Clean up project structure and add Archlinux PKGBUILDS --- .gitignore | 3 +- README.md | 205 +++-- arch/hp-wmi-omen/PKGBUILD | 30 + arch/omen-fan-control/PKGBUILD | 49 ++ omen_cli.py | 721 ------------------ pyproject.toml | 46 ++ src/omen_fan_control/__init__.py | 31 + src/omen_fan_control/cli.py | 569 ++++++++++++++ src/omen_fan_control/data/LICENSE.md | 187 +++++ .../omen_fan_control/data/driver/Makefile | 0 .../omen_fan_control/data/driver/dkms.conf | 0 .../data/driver/hooks}/90-hp-wmi-omen.hook | 0 .../data/driver/hooks}/99-hp-wmi-omen.install | 0 .../data/driver/hooks}/zz-hp-wmi-omen | 0 .../omen_fan_control/data/driver/hp-wmi.c | 0 .../data/driver/hp-wmi.c.orig | 0 .../data/driver/install_driver.sh | 0 .../omen_fan_control/fan_curve_widget.py | 8 +- omen_gui.py => src/omen_fan_control/gui.py | 21 +- .../omen_fan_control/logic.py | 470 ++++-------- uv.lock | 256 +++++++ 21 files changed, 1446 insertions(+), 1150 deletions(-) create mode 100644 arch/hp-wmi-omen/PKGBUILD create mode 100644 arch/omen-fan-control/PKGBUILD delete mode 100644 omen_cli.py create mode 100644 pyproject.toml create mode 100644 src/omen_fan_control/__init__.py create mode 100644 src/omen_fan_control/cli.py create mode 100644 src/omen_fan_control/data/LICENSE.md rename Makefile => src/omen_fan_control/data/driver/Makefile (100%) rename dkms.conf => src/omen_fan_control/data/driver/dkms.conf (100%) rename {hooks => src/omen_fan_control/data/driver/hooks}/90-hp-wmi-omen.hook (100%) rename {hooks => src/omen_fan_control/data/driver/hooks}/99-hp-wmi-omen.install (100%) rename {hooks => src/omen_fan_control/data/driver/hooks}/zz-hp-wmi-omen (100%) rename hp-wmi.c => src/omen_fan_control/data/driver/hp-wmi.c (100%) rename hp-wmi.c.orig => src/omen_fan_control/data/driver/hp-wmi.c.orig (100%) rename install_driver.sh => src/omen_fan_control/data/driver/install_driver.sh (100%) rename fan_curve_widget.py => src/omen_fan_control/fan_curve_widget.py (95%) rename omen_gui.py => src/omen_fan_control/gui.py (99%) rename omen_logic.py => src/omen_fan_control/logic.py (56%) create mode 100644 uv.lock diff --git a/.gitignore b/.gitignore index 35251d5..410f60c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ dev tests -__pycache__ \ No newline at end of file +__pycache__ +**/__pycache__ diff --git a/README.md b/README.md index a11778b..dccab6b 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,10 @@ This tool provides fan control for HP Omen Max, Victus and Omen laptops on Linux ## Context This tool includes a backported `hp-wmi` driver patch from the upcoming Linux 6.20 kernel, which introduces native fan control support for many devices from the following models: -1. **HP Omen Max** -2. **HP Victus** -3. **HP Omen** + +1. **HP Omen Max** +2. **HP Victus** +3. **HP Omen** The patch can be installed on versions before `6.20`. @@ -15,147 +16,183 @@ The patch can be installed on versions before `6.20`. [platform/x86: hp-wmi: add manual fan control for Victus S models](https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/commit/?h=for-next&id=46be1453e6e61884b4840a768d1e8ffaf01a4c1c) This program also includes a modification that sets the max speed according to calibration if the query to get the Max RPM fails for your device. + ## Tested Hardware -* **Model:** HP OMEN MAX 16-AH0001NT (8D41) -* **OS:** Arch Linux 6.18.6 +- **Model:** HP OMEN MAX 16-AH0001NT (8D41) +- **OS:** Arch Linux 6.18.6 ## Installation -### Clone the repository -Clone the repository or download the latest source code from the [Releases](https://github.com/arfelious/omen-fan-control/releases) page. +Choose one of the following: **pipx/uv** (recommended), **Arch Linux packages**, or **clone + run from source**. + +### Option A: pipx or uv (recommended) + +Install the app in an isolated environment. Driver sources are bundled; you can run `install-patch` from the app. + +**Using pipx:** + +```bash +pipx install git+https://github.com/arfelious/omen-fan-control.git +# Then: +sudo omen-fan-control status +sudo omen-fan-control-gui # GUI +``` + +**Using uv:** + +```bash +uv tool install git+https://github.com/arfelious/omen-fan-control.git +sudo omen-fan-control status +sudo omen-fan-control-gui +``` + +**System deps (for driver build):** install kernel headers and build tools (e.g. Arch: `linux-headers base-devel`, Debian/Ubuntu: `linux-headers-$(uname -r) build-essential`). + +### Option B: Arch Linux (PKGBUILD) + +Two packages: the **DKMS kernel module** (optional; persists across kernel updates) and the **Python app**. + +1. **Kernel module (DKMS)** – from repo: + ```bash + cd omen-fan-control/arch/hp-wmi-omen && makepkg -si + ``` + This installs `hp-wmi-omen-dkms`. Alternatively, install the driver from the app (see Option C). +2. **Python application** – from repo root: + ```bash + makepkg -p arch/omen-fan-control/PKGBUILD -sf + sudo pacman -U omen-fan-control-*.pkg.tar.zst + ``` + Driver data is installed under `/usr/share/omen-fan-control`; the app uses it when you run `install-patch permanent` (e.g. for calibration-based patching). Set `OMEN_FAN_CONTROL_DIR=/usr/share/omen-fan-control` if not using the provided `profile.d` snippet. + +### Option C: Clone and run from source (single copy under `src/`) + +All code and driver sources live under `src/` ```bash git clone https://github.com/arfelious/omen-fan-control.git cd omen-fan-control ``` -### Dependencies +**Dependencies** -**1. System Dependencies** -You must install kernel headers and build tools for the driver patch to compile. -* **Arch:** `pacman -S linux-headers base-devel` -* **Debian/Ubuntu:** `apt install linux-headers-$(uname -r) build-essential` +- **System:** kernel headers and build tools (Arch: `pacman -S linux-headers base-devel`; Debian/Ubuntu: `apt install linux-headers-$(uname -r) build-essential`). +- **Python:** `click`, `PyQt6`. Either use **uv** (recommended) or pip. -**2. Python Dependencies** -You can install the required Python packages (`click`, `PyQt6`) via your package manager OR pip, preferably with a virtual environment. +**Run from repo (no install)** -* **Option A: Package Manager** - * **Arch:** `pacman -S python-click python-pyqt6` - * **Debian/Ubuntu:** `apt install python3-click python3-pyqt6` +With **uv** (adds project to path automatically): -* **Option B: Pip** - ```bash - pip install -r requirements.txt - ``` +```bash +uv sync +uv run omen-fan-control --help +uv run omen-fan-control-gui +sudo uv run omen-fan-control install-patch permanent +sudo uv run omen-fan-control service install +``` -### Install Driver Patch -You can install the modified driver temporarily (current session) or permanently (DKMS-style patch). +With **pip** (run the package module with `src` on `PYTHONPATH`): ```bash -# Permanent Installation (Recommended) -sudo python3 omen_cli.py install-patch permanent - -# Temporary Installation (Until Reboot) -sudo python3 omen_cli.py install-patch temporary +pip install -r requirements.txt +export PYTHONPATH=src +python -m omen_fan_control.cli --help +python -m omen_fan_control.gui +sudo env PYTHONPATH=src python -m omen_fan_control.cli install-patch permanent +sudo env PYTHONPATH=src python -m omen_fan_control.cli service install ``` -### Install Background Service -For proper curve control and watchdog operation, install the background service: +Or install the package in editable mode and use the same commands as pipx: ```bash -sudo python3 omen_cli.py service install +uv sync # or: pip install -e . +uv run omen-fan-control status +sudo uv run omen-fan-control-gui ``` -You can also install it from the settings page in the graphical interface. ## Usage + +- **Installed** (pipx, uv tool, or Arch): run `omen-fan-control` and `omen-fan-control-gui`. +- **From clone:** run `uv run omen-fan-control` / `uv run omen-fan-control-gui`, or `PYTHONPATH=src python -m omen_fan_control.cli` / `python -m omen_fan_control.gui`. + +Examples below use `omen-fan-control`; from clone use one of the forms above. + ### GUI -A graphical interface is available for simpler configuration. + ```bash -sudo python3 omen_gui.py +sudo omen-fan-control-gui ``` + **GUI Fan Curve** -|Omen Fan Control GUI| -|---| + +| | +| --- | ### CLI -The `omen_cli.py` script manages everything. -**Check Status:** -```bash -sudo python3 omen_cli.py status -``` -**Possible Settings** -```bash -python omen_cli.py settings --help -``` -**Current Settings Configuration** +**Check status** + ```bash -python omen_cli.py settings +sudo omen-fan-control status ``` -**Set Settings (Moving Average Window, etc.):** +**Settings** + ```bash -sudo python3 omen_cli.py options --ma-window 10 --curve-interpolation smooth +omen-fan-control settings --help +omen-fan-control settings +sudo omen-fan-control options --ma-window 10 --curve-interpolation smooth ``` -**Manual Fan Control:** +**Fan control** + ```bash -# Set specific speed -sudo python3 omen_cli.py fan-control --mode manual --value 80% +# Manual speed +sudo omen-fan-control fan-control --mode manual --value 80% -# Set Curve Mode (requires service) -sudo python3 omen_cli.py fan-control --mode curve +# Curve mode (requires service) +sudo omen-fan-control fan-control --mode curve -# Set Auto (Default) -sudo python3 omen_cli.py fan-control --mode auto -``` +# Auto (default) +sudo omen-fan-control fan-control --mode auto -**Using Custom Curves:** -```bash -sudo python3 omen_cli.py fan-control --curve-csv my_curve.csv +# Custom curve CSV (temp, percent per line) +sudo omen-fan-control fan-control --curve-csv my_curve.csv ``` -Where the csv file has values in `temp, percent` order - -
-**Detailed Information** +**Other** -Commands provide detailed information when `--help` is passed with the command ```bash -python omen_cli.py fan-control --help +omen-fan-control fan-control --help ``` ## Uninstallation -To remove the service and restore the original kernel driver: - -1. **Remove Service:** - ```bash - sudo python3 omen_cli.py service remove - ``` - -2. **Restore Driver:** - ```bash - sudo python3 omen_cli.py install-patch restore - ``` - This restores the original `.ko` files from the backups created during installation. +1. **Remove service** + ```bash + sudo omen-fan-control service remove + ``` +2. **Restore original driver** + ```bash + sudo omen-fan-control install-patch restore + ``` + Restores the original `.ko` files from backups created during installation. ## Disclaimer **USE AT YOUR OWN RISK.** Modifying kernel drivers and manipulating thermal control systems can potentially damage your hardware or cause instability. This software is provided "as is" without warranty of any kind. This was tested on my personal hardware, and the used `hp-wmi.c` is a patched version of the one in the upcoming `6.20` kernel, so your mileage may vary. -
-Acknowledgements -
+Acknowledgements + **Probes:** -- https://github.com/alou-S/omen-fan/blob/main/docs/probes.md + +- [https://github.com/alou-S/omen-fan/blob/main/docs/probes.md](https://github.com/alou-S/omen-fan/blob/main/docs/probes.md) **Linux 6.20 Kernel HP-WMI Driver:** -- https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/commit/?h=for-next&id=46be1453e6e61884b4840a768d1e8ffaf01a4c1c -
+- [https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/commit/?h=for-next&id=46be1453e6e61884b4840a768d1e8ffaf01a4c1c](https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/commit/?h=for-next&id=46be1453e6e61884b4840a768d1e8ffaf01a4c1c) + diff --git a/arch/hp-wmi-omen/PKGBUILD b/arch/hp-wmi-omen/PKGBUILD new file mode 100644 index 0000000..939570a --- /dev/null +++ b/arch/hp-wmi-omen/PKGBUILD @@ -0,0 +1,30 @@ +# DKMS kernel module: patched hp-wmi for HP Omen/Victus fan control (Linux < 6.20) +# Reference: https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/commit/?h=for-next&id=46be1453e6e61884b4840a768d1e8ffaf01a4c1c +_pkgbase=hp-wmi-omen +pkgname="${_pkgbase}-dkms" +pkgver=1.0 +pkgrel=1 +pkgdesc="Patched hp-wmi driver for HP Omen/Victus fan control (DKMS; for kernels < 6.20)" +url="https://github.com/arfelious/omen-fan-control" +license=("GPL") +arch=("x86_64") +depends=("dkms" "linux-headers") +makedepends=() +conflicts=() +provides=("hp-wmi-omen") + +source=( + "../../src/omen_fan_control/data/driver/hp-wmi.c" + "../../src/omen_fan_control/data/driver/hp-wmi.c.orig" + "../../src/omen_fan_control/data/driver/Makefile" + "../../src/omen_fan_control/data/driver/dkms.conf" +) +sha256sums=("SKIP" "SKIP" "SKIP" "SKIP") + +package() { + local dkms_dir="/usr/src/${_pkgbase}-${pkgver}" + install -Dm644 hp-wmi.c "${pkgdir}${dkms_dir}/hp-wmi.c" + install -Dm644 hp-wmi.c.orig "${pkgdir}${dkms_dir}/hp-wmi.c.orig" + install -Dm644 Makefile "${pkgdir}${dkms_dir}/Makefile" + install -Dm644 dkms.conf "${pkgdir}${dkms_dir}/dkms.conf" +} diff --git a/arch/omen-fan-control/PKGBUILD b/arch/omen-fan-control/PKGBUILD new file mode 100644 index 0000000..b428dbb --- /dev/null +++ b/arch/omen-fan-control/PKGBUILD @@ -0,0 +1,49 @@ +# Python application: CLI and GUI for HP Omen/Victus fan control +# Install driver separately (hp-wmi-omen-dkms) or use "omen-fan-control install-patch" from this app. +pkgname=omen-fan-control +pkgver=1.0.0 +pkgrel=1 +pkgdesc="Fan control for HP Omen Max, Victus and Omen laptops on Linux (CLI + GUI)" +url="https://github.com/arfelious/omen-fan-control" +license=("GPL-3.0-or-later") +arch=("any") +depends=("python-click" "python-pyqt6") +makedepends=("python-build" "python-installer" "python-hatchling") +optdepends=("hp-wmi-omen-dkms: persist patched driver across kernel updates") +# One file so makepkg sets srcdir; prepare() copies rest from repo (run from repo root: makepkg -p arch/omen-fan-control/PKGBUILD) +source=("../../pyproject.toml") +sha256sums=("SKIP") + +prepare() { + local repo_root + repo_root="$(cd "${startdir}/../.." && pwd)" + cp -f "$repo_root/README.md" "$repo_root/LICENSE.md" "$srcdir/" 2>/dev/null || true + cp -r "$repo_root/src" "$srcdir/" +} + +build() { + cd "$srcdir" + python -m build --wheel --no-isolation +} + +package() { + local whl + whl=$(echo "$srcdir"/dist/omen_fan_control*.whl) + python -m installer --compile-bytecode=0 -d "$pkgdir" "$whl" + + # Driver data for "install-patch permanent" (OMEN_FAN_CONTROL_DIR used by app) + install -dm755 "$pkgdir/usr/share/omen-fan-control/driver/hooks" + install -Dm644 "$srcdir/src/omen_fan_control/data/driver/hp-wmi.c" "$pkgdir/usr/share/omen-fan-control/driver/hp-wmi.c" + install -Dm644 "$srcdir/src/omen_fan_control/data/driver/hp-wmi.c.orig" "$pkgdir/usr/share/omen-fan-control/driver/hp-wmi.c.orig" + install -Dm644 "$srcdir/src/omen_fan_control/data/driver/Makefile" "$pkgdir/usr/share/omen-fan-control/driver/Makefile" + install -Dm644 "$srcdir/src/omen_fan_control/data/driver/dkms.conf" "$pkgdir/usr/share/omen-fan-control/driver/dkms.conf" + install -Dm755 "$srcdir/src/omen_fan_control/data/driver/install_driver.sh" "$pkgdir/usr/share/omen-fan-control/driver/install_driver.sh" + for f in "$srcdir/src/omen_fan_control/data/driver/hooks/"*; do + [[ -f "$f" ]] && install -Dm644 "$f" "$pkgdir/usr/share/omen-fan-control/driver/hooks/$(basename "$f")" + done + + # systemd drop-in or profile.d so OMEN_FAN_CONTROL_DIR is set for all users + install -dm755 "$pkgdir/etc/profile.d" + printf '%s\n' 'export OMEN_FAN_CONTROL_DIR=/usr/share/omen-fan-control' > "$pkgdir/etc/profile.d/omen-fan-control.sh" + chmod 644 "$pkgdir/etc/profile.d/omen-fan-control.sh" +} diff --git a/omen_cli.py b/omen_cli.py deleted file mode 100644 index 12e5efd..0000000 --- a/omen_cli.py +++ /dev/null @@ -1,721 +0,0 @@ -#!/usr/bin/env python3 -# Omen Fan Control -# Control your HP Laptop's fans in Linux -# Copyright (C) 2026 arfelious -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -import click -import sys -from omen_logic import FanController, OMEN_FAN_DIR - -@click.group() -@click.option('--config', type=click.Path(), help="Path to custom config file") -@click.option('--help-extra', is_flag=True, help="Show extra/advanced commands help") -@click.pass_context -def cli(ctx, config, help_extra): - """HP Omen Fan Control CLI""" - if help_extra: - click.echo("Extra / Advanced Commands:") - click.echo(" disable-bios Disable BIOS fan control (writes to EC)") - click.echo(" enable-bios Enable BIOS fan control (writes to EC)") - click.echo("\n Note: Disabling BIOS control is usually unnecessary as the driver handles overrides.") - ctx.exit() - - ctx.ensure_object(dict) - ctx.obj['config_path'] = config - - # Root check - import os - controller = FanController(config_path=config) - if os.geteuid() != 0 and not controller.config.get("bypass_root_warning", False): - click.echo(click.style("WARNING: Running without root privileges.", fg="yellow")) - click.echo(click.style("Most commands require root to function correctly.", fg="yellow")) - click.echo(click.style("Use --bypass-root-warning in 'omen_cli.py options' config to hide this.", dim=True)) - click.echo("", err=True) - - # Board support check - if not controller.config.get("bypass_warning", False): - status, board = controller.check_board_support() - if status == "UNSUPPORTED": - click.echo(click.style(f"WARNING: Your board '{board}' is not in the known compatible list.", fg="red")) - click.echo(click.style("Using this tool could potentially cause system instability.", fg="red")) - click.echo("To bypass this warning, set 'bypass_warning' to true in config or toggle in GUI.") - - - elif status == "POSSIBLY_SUPPORTED" and not controller.config.get("enable_experimental", False): - click.echo(click.style(f"NOTE: Your board '{board}' is valid for experimental support.", fg="yellow")) - click.echo(click.style("Community patches suggest it uses the Omen thermal path.", fg="yellow")) - click.echo("You can enable experimental support in the GUI Settings or by editing config.json:") - click.echo(' "enable_experimental": true, "thermal_profile": "omen" (or victus/victus_s)') - click.echo("") - -def get_controller(): - ctx = click.get_current_context() - config_path = ctx.obj.get('config_path') if ctx.obj else None - return FanController(config_path=config_path) - -@cli.command() -def calibrate(): - """Run fan calibration to determine max RPM.""" - controller = get_controller() - if click.confirm("This will spin fans at max speed for calibration. Continue?"): - prev_mode = controller.config.get("mode", "auto") - controller.config["mode"] = "calibration" - controller.save_config() - - try: - gen = controller.calibrate() - max_rpm = 0 - try: - while True: - progress = next(gen) - click.echo(f"Calibrating... {progress}%", nl=False) - click.echo("\r", nl=False) - except StopIteration as e: - max_rpm = e.value - - click.echo(f"\nCalibration finished. Max RPM: {max_rpm}") - - finally: - controller.config["mode"] = prev_mode - controller.save_config() - -@cli.command() -@click.argument('install_type', required=False) -@click.option('--temp', is_flag=True, help="Legacy: Install temporarily") -@click.option('--perm', is_flag=True, help="Legacy: Install permanently") -@click.option('--restore', is_flag=True, help="Legacy: Restore original") -def install_patch(install_type, temp, perm, restore): - """ - Install the fan driver patch or restore original. - - \b - INSTALL_TYPE can be: - t, temp, temporary : Install temporarily (until reboot) - p, perm, permanent : Install permanently (patches source) - r, restore : Restore original driver from backups - """ - controller = get_controller() - - mode = None - - if install_type: - install_type = install_type.lower() - if install_type in ['t', 'temp', 'temporary']: - mode = 'temp' - elif install_type in ['p', 'perm', 'permanent']: - mode = 'perm' - elif install_type in ['r', 'restore']: - mode = 'restore' - - if not mode: - if temp: mode = 'temp' - elif perm: mode = 'perm' - elif restore: mode = 'restore' - - if not mode: - click.echo("Please specify installation type: t (temp, temporary), p (perm, permanent), or r (restore).") - click.echo("Example: omen_cli.py install-patch temporary") - return - - if mode == 'temp': - click.echo("Installing temporary driver...") - success, msg = controller.install_driver_temp() - if not success and msg == "PWM_DETECTED": - itype = controller.check_install_type() - msg_add = "" - if itype == "temporary": - msg_add = "\n(The current installation may be temporary)" - - if click.confirm(f"Driver seems to be already active/installed.{msg_add}\nForce re-install?"): - success, msg = controller.install_driver_temp(force=True) - - click.echo(msg) - if not success: sys.exit(1) - - elif mode == 'perm': - click.echo("Installing permanent driver...") - success, msg = controller.install_driver_perm() - if not success and msg == "PWM_DETECTED": - itype = controller.check_install_type() - msg_add = "" - if itype == "temporary": - msg_add = "\n(The current installation may be temporary)" - - if click.confirm(f"Driver seems to be already active/installed.{msg_add}\nForce re-install?"): - success, msg = controller.install_driver_perm(force=True) - - click.echo(msg) - if not success: sys.exit(1) - - elif mode == 'restore': - click.echo("Restoring original driver...") - success, msg = controller.restore_driver() - click.echo(msg) - if not success: sys.exit(1) - -@cli.command() -@click.option('--mode', type=click.Choice(['auto', 'max', 'manual', 'curve', 'last']), help="Set fan mode. 'last' loads from config.") -@click.option('--value', required=False, help="Manual value: 0-255 (PWM) or 0-100% (e.g. '50%')") -@click.option('--curve-csv', required=False, type=click.Path(exists=True), help="CSV file for curve mode (format: temp,percent)") -@click.argument('action', required=False) -def fan_control(mode, value, curve_csv, action): - """ - Control fan mode and speed. - Usage: - fan-control --mode auto - fan-control set (Applies last saved mode) - """ - if mode is None: - if curve_csv: - mode = 'curve' - elif action == 'set': - mode = 'last' - else: - ctx = click.get_current_context() - click.echo(ctx.get_help()) - ctx.exit() - - controller = get_controller() - - from pathlib import Path - default_conf = Path("/etc/omen-fan-control/config.json") - if controller.is_service_running() and controller.config_path.resolve() != default_conf.resolve(): - click.echo(click.style("WARNING: Background service is active using system config.", fg="yellow")) - click.echo(click.style(f"It will likely overwrite your changes from {controller.config_path.name} immediately.", fg="yellow")) - click.echo("Suggestion: Stop the service ('omen_cli.py service stop') before testing custom configs.\n") - - if mode == 'last': - mode = controller.config.get("mode", "auto") - click.echo(f"Applying last saved mode: {mode.upper()}") - - if mode == 'auto': - controller.set_fan_mode('auto') - click.echo("Fan set to AUTO.") - elif mode == 'max': - controller.set_fan_mode('max') - click.echo("Fan set to MAX.") - elif mode == 'manual': - # Check driver requirement - has_driver = controller.pwm1_path and controller.pwm1_path.exists() - if not has_driver: - click.echo(f"Error: Manual mode requires the kernel driver patch (pwm1 not found).") - click.echo("Run 'omen_cli.py install-patch perm' to install it.") - sys.exit(1) - - if value is None: - click.echo("Please specify --value (0-255 or 0-100%) for manual mode") - return - - try: - pwm_val = 0 - val_str = str(value).strip() - if val_str.endswith('%'): - percent = int(val_str[:-1]) - if not (0 <= percent <= 100): - click.echo("Error: Percentage must be 0-100.") - return - pwm_val = int(round(percent / 100 * 255)) - click.echo(f"Setting speed to {percent}% (PWM: {pwm_val})") - else: - pwm_val = int(val_str) - if not (0 <= pwm_val <= 255): - click.echo("Error: PWM value must be 0-255.") - return - click.echo(f"Setting PWM to {pwm_val}") - - controller.config["mode"] = "manual" - controller.config["manual_pwm"] = pwm_val - controller.save_config() - controller.set_fan_pwm(pwm_val) - - except ValueError: - click.echo(f"Error: Invalid value format '{value}'. Use integer 0-255 or percentage '50%'.") - return - - elif mode == 'curve': - has_driver = controller.pwm1_path and controller.pwm1_path.exists() - if not has_driver: - click.echo(f"Error: Curve mode requires the kernel driver patch (pwm1 not found).") - click.echo("Run 'omen_cli.py install-patch perm' to install it.") - sys.exit(1) - - if curve_csv: - points = [] - try: - with open(curve_csv, 'r') as f: - for line in f: - line = line.strip() - if not line or line.startswith('#'): continue - if ',' not in line: continue - - parts = line.split(',') - if len(parts) >= 2: - temp = int(parts[0].strip()) - speed = int(parts[1].strip()) - if not (0 <= temp <= 105): - click.echo(f"Warning: Temp {temp} out of usual range (0-105).") - if not (0 <= speed <= 100): - click.echo(f"Error: Speed {speed} must be 0-100%.") - return - points.append([temp, speed]) - - if not points: - click.echo("Error: No valid points found in CSV.") - return - - points.sort(key=lambda x: x[0]) - controller.config["curve"] = points - click.echo(f"Loaded {len(points)} points from CSV.") - - except Exception as e: - click.echo(f"Error reading CSV: {e}") - return - - controller.config["mode"] = "curve" - controller.save_config() - click.echo("Curve mode enabled in config.") - - if not controller.is_service_installed(): - click.echo("WARNING: Background service is NOT installed/running. Curve mode requires the service to be active.") - click.echo("Run 'omen_cli.py install-patch perm' (if needed) and ensure service is started.") - click.echo(" sudo systemctl start omen-fan-control.service") - click.echo("Or run 'omen_cli.py serve' manually to keep it running.") - else: - click.echo("Service should pick up the change automatically.") - -@cli.command() -def serve(): - """Run the fan control daemon (foreground). Used by systemd service.""" - import time - controller = get_controller() - click.echo("Starting Omen Fan Control Daemon...") - - ma_window = controller.config.get("ma_window", 5) - temp_history = [] - - watchdog_interval = controller.config.get("watchdog_interval", 90) - last_watchdog_time = time.time() - hysteresis_start_time = None - - last_config_mtime = 0 - - while True: - try: - try: - current_mtime = controller.config_path.stat().st_mtime - if current_mtime > last_config_mtime: - controller.config = controller.load_config() - last_config_mtime = current_mtime - except Exception: - # If file doesn't exist or error, ignore - pass - - mode = controller.config.get("mode", "auto") - - if mode == "calibration": - time.sleep(1) - continue - - if time.time() - last_watchdog_time > watchdog_interval: - last_watchdog_time = time.time() - - current_temp = controller.get_cpu_temp() - - ma_window = controller.config.get("ma_window", 5) - temp_history.append(current_temp) - if len(temp_history) > ma_window: - temp_history.pop(0) - avg_temp = sum(temp_history) / len(temp_history) - - if mode == "curve": - target_pwm = controller.calculate_target_pwm(avg_temp) - if target_pwm is not None: - current_rpm = controller.get_fan_speed() - max_rpm = controller.config.get("fan_max", 0) - - should_apply = True - - if max_rpm > 0: - target_rpm = (target_pwm / 255) * max_rpm - diff = abs(target_rpm - current_rpm) - - if diff <= 200: - if hysteresis_start_time is None: - hysteresis_start_time = time.time() - - if time.time() - hysteresis_start_time > 60: - should_apply = True - else: - should_apply = False - else: - hysteresis_start_time = None - should_apply = True - - if should_apply: - controller.set_fan_pwm(target_pwm) - hysteresis_start_time = None - - elif mode == "manual": - manual_val = controller.config.get("manual_pwm", -1) - if manual_val >= 0: - controller.set_fan_pwm(manual_val) - - elif mode == "max": - controller.set_fan_mode("max") - - elif mode == "auto": - controller.set_fan_mode("auto") - - time.sleep(2) - - except KeyboardInterrupt: - click.echo("Stopping daemon...") - break - except Exception as e: - click.echo(f"Error in daemon loop: {e}") - time.sleep(5) - -@cli.command() -@click.argument('duration', required=True) -def stress(duration): - """ - Run CPU stress test for specified DURATION. - - \b - DURATION format examples: - 30s - Run for 30 seconds - 1m - Run for 1 minute - 5m - Run for 5 minutes - 1h - Run for 1 hour - """ - import time - controller = get_controller() - - try: - duration_str = duration.lower().strip() - seconds = 0 - if duration_str.endswith('s'): - seconds = int(duration_str[:-1]) - elif duration_str.endswith('m'): - seconds = int(duration_str[:-1]) * 60 - elif duration_str.endswith('h'): - seconds = int(duration_str[:-1]) * 3600 - else: - seconds = int(duration_str) - - if seconds <= 0: - click.echo("Error: Duration must be positive.") - return - - except ValueError: - click.echo(f"Error: Invalid duration format '{duration}'. Use '30s', '1m', etc.") - return - - click.echo(f"Starting CPU Stress Test for {seconds} seconds...") - click.echo("Press Ctrl+C to stop manually.") - - if controller.start_stress_test(seconds): - try: - start_time = time.time() - while time.time() - start_time < seconds: - elapsed = int(time.time() - start_time) - remaining = seconds - elapsed - print(f"Time remaining: {remaining}s ", end='\r') - time.sleep(1) - except KeyboardInterrupt: - click.echo("\nStress test cancelled by user.") - finally: - controller.stop_stress_test() - click.echo("\nStress test stopped.") - else: - click.echo("Failed to start stress test processes.") - -@cli.command() -@click.option('--wait-time', type=int, required=False, is_flag=False, flag_value=-1, help="Time to wait during calibration (seconds). No arg shows current.") -@click.option('--watchdog', type=int, required=False, is_flag=False, flag_value=-1, help="Watchdog interval (seconds). No arg shows current.") -@click.option('--ma-window', type=int, required=False, is_flag=False, flag_value=-1, help="Moving Average Window size. No arg shows current.") -@click.option('--bypass-warning', type=click.Choice(['on', 'off']), required=False, is_flag=False, flag_value='show', help="Bypass driver patch warning. No arg shows current.") -@click.option('--curve-interpolation', type=click.Choice(['smooth', 'discrete']), required=False, is_flag=False, flag_value='show', help="Curve interpolation mode. No arg shows current.") -@click.option('--enable-experimental', type=click.Choice(['on', 'off']), required=False, is_flag=False, flag_value='show', help="Enable experimental board support. No arg shows current.") -@click.option('--thermal-profile', type=click.Choice(['omen', 'victus', 'victus_s']), required=False, is_flag=False, flag_value='show', help="Set thermal profile for exp. support. No arg shows current.") -def options(wait_time, watchdog, ma_window, bypass_warning, curve_interpolation, enable_experimental, thermal_profile): - """ - Configure or view options. - Run without arguments to view all current settings. - Run with flag (e.g. --wait-time) to view specific setting. - Run with flag and value (e.g. --wait-time 10) to set value. - """ - controller = get_controller() - - if all(x is None for x in [wait_time, watchdog, ma_window, bypass_warning, curve_interpolation]): - wt = controller.config.get('calibration_wait', 5) - wd = controller.config.get('watchdog_interval', 90) - mw = controller.config.get('ma_window', 5) - bp = controller.config.get('bypass_patch_warning', False) - ci = controller.config.get('curve_interpolation', 'smooth') - ee = controller.config.get('enable_experimental', False) - tp = controller.config.get('thermal_profile', 'omen') - - click.echo("Current Configuration:") - click.echo(f" Calibration Wait Time: {wt}s \t--wait-time") - click.echo(f" Watchdog Interval: {wd}s \t--watchdog") - click.echo(f" MA Window (Smoothing): {mw} \t--ma-window") - click.echo(f" Bypass Warning: {'On' if bp else 'Off'} \t--bypass-warning") - click.echo(f" Curve Interpolation: {ci} \t--curve-interpolation") - click.echo(f" Experimental Support: {'On' if ee else 'Off'} \t--enable-experimental") - click.echo(f" Thermal Profile: {tp} \t--thermal-profile") - return - - changed = False - - if wait_time is not None: - if wait_time == -1: - val = controller.config.get('calibration_wait', 5) - click.echo(f"Current Calibration Wait Time: {val}s") - elif wait_time > 0: - controller.config['calibration_wait'] = wait_time - changed = True - click.echo(f"Calibration wait time set to {wait_time}s") - else: - click.echo("Error: Wait time must be positive.") - - if watchdog is not None: - if watchdog == -1: - val = controller.config.get('watchdog_interval', 90) - click.echo(f"Current Watchdog Interval: {val}s") - elif watchdog > 0: - controller.config['watchdog_interval'] = watchdog - changed = True - click.echo(f"Watchdog interval set to {watchdog}s") - else: - click.echo("Error: Watchdog interval must be positive.") - - if ma_window is not None: - if ma_window == -1: - val = controller.config.get('ma_window', 5) - click.echo(f"Current MA Window: {val}") - elif ma_window > 0: - controller.config['ma_window'] = ma_window - changed = True - click.echo(f"MA Window set to {ma_window}") - else: - click.echo("Error: MA Window must be positive.") - - if bypass_warning is not None: - if bypass_warning == 'show': - val = controller.config.get('bypass_patch_warning', False) - click.echo(f"Current Bypass Warning: {'On' if val else 'Off'}") - else: - is_on = (bypass_warning == 'on') - controller.config['bypass_patch_warning'] = is_on - changed = True - click.echo(f"Bypass Warning set to {'On' if is_on else 'Off'}") - - if enable_experimental is not None: - if enable_experimental == 'show': - val = controller.config.get('enable_experimental', False) - click.echo(f"Current Experimental Support: {'On' if val else 'Off'}") - else: - is_on = (enable_experimental == 'on') - controller.config['enable_experimental'] = is_on - changed = True - click.echo(f"Experimental Support set to {'On' if is_on else 'Off'}") - - if thermal_profile is not None: - if thermal_profile == 'show': - val = controller.config.get('thermal_profile', 'omen') - click.echo(f"Current Thermal Profile: {val}") - else: - controller.config['thermal_profile'] = thermal_profile - changed = True - click.echo(f"Thermal Profile set to {thermal_profile}") - - if curve_interpolation is not None: - if curve_interpolation == 'show': - val = controller.config.get('curve_interpolation', 'smooth') - click.echo(f"Current Interpolation: {val}") - else: - controller.config['curve_interpolation'] = curve_interpolation - changed = True - click.echo(f"Curve Interpolation set to {curve_interpolation}") - - if changed: - controller.save_config() - -@cli.group() -def service(): - """Manage background service""" - pass - -@service.command(name="install") -def install_service_cmd(): - """Install and enable the background service""" - controller = get_controller() - click.echo("Installing background service...") - success, msg = controller.create_service() - click.echo(msg) - -@service.command(name="remove") -def remove_service_cmd(): - """Stop and remove the background service""" - controller = get_controller() - click.echo("Removing background service...") - success, msg = controller.remove_service() - click.echo(msg) - -@service.command(name="restart") -def restart_service_cmd(): - """Restart the background service""" - controller = get_controller() - click.echo("Restarting background service...") - success, msg = controller.restart_service() - click.echo(msg) - -@service.command(name="status") -def service_status_cmd(): - """Check service status""" - controller = get_controller() - installed = controller.is_service_installed() - running = controller.is_service_running() - - click.echo(f"Service Installed: {'Yes' if installed else 'No'}") - click.echo(f"Service Running: {'Yes' if running else 'No'}") - -@cli.command() -def status(): - """Show comprehensive system status (Temps, Fan, Service)""" - controller = get_controller() - - # 1. Service Status - is_running = controller.is_service_running() - status_str = click.style("RUNNING", fg="green") if is_running else click.style("STOPPED", fg="red") - if not controller.is_service_installed(): - status_str = click.style("NOT INSTALLED", fg="yellow") - click.echo(f"Service Status: {status_str}") - - # Installation Type - install_type = controller.check_install_type() - type_str = "None" - if install_type == "permanent": - type_str = click.style("Permanent", fg="green") - elif install_type == "temporary": - type_str = click.style("Temporary (Session)", fg="yellow") - click.echo(f"Driver Install: {type_str}") - - mode = "Unknown" - try: - enable = controller.read_sys_file(controller.pwm1_enable_path) - if enable == "0": mode = "Max (0)" - elif enable == "1": - # Manual mode could mean fixed manual OR curve service - if controller.is_service_running(): - config_mode = controller.config.get("mode", "manual") - if config_mode == "curve": - mode = "Curve (Service)" - elif config_mode == "manual": - val = controller.config.get("manual_pwm", 0) - mode = f"Manual Fixed ({val})" - else: - mode = f"Manual (Service: {config_mode})" - else: - mode = "Manual (1)" - elif enable == "2": mode = "Auto (2)" - else: mode = f"Unknown ({enable})" - except: - mode = "N/A" - click.echo(f"Driver Mode: {mode}") - - # 3. Fan Speed - rpm = controller.get_fan_speed() - click.echo(f"Fan Speed: {rpm} RPM") - - # 4. Temperatures - pkg_temp = controller.get_cpu_temp() - click.echo(f"CPU Package Temp: {pkg_temp}°C") - - click.echo("\nCore Temperatures:") - cores = controller.get_all_core_temps() - if cores: - for label, temp in cores: - click.echo(f" {label:<15} {temp}°C") - else: - click.echo(" (No core temp sensors found)") - -@cli.command(hidden=True) -def disable_bios(): - """Disable BIOS fan control (Enable Manual Mode)""" - controller = get_controller() - if click.confirm("This will write to EC registers to disable BIOS fan control. Continue?"): - if controller.set_bios_control(False): - click.echo("BIOS control disabled (Manual mode enabled).") - else: - click.echo("Failed to disable BIOS control.") - -@cli.command(hidden=True) -def enable_bios(): - """Enable BIOS fan control (Disable Manual Mode)""" - controller = get_controller() - if controller.set_bios_control(True): - click.echo("BIOS control enabled (Manual mode disabled).") - else: - click.echo("Failed to enable BIOS control.") - -@cli.command() -@click.option('--wait-time', type=int, required=False, is_flag=False, flag_value=-1, help="Time to wait during calibration (seconds). No arg shows current.") -@click.option('--watchdog', type=int, required=False, is_flag=False, flag_value=-1, help="Watchdog interval (seconds). No arg shows current.") -@click.option('--ma-window', type=int, required=False, is_flag=False, flag_value=-1, help="Moving Average Window size. No arg shows current.") -@click.option('--bypass-warning', type=click.Choice(['on', 'off']), required=False, is_flag=False, flag_value='show', help="Bypass driver patch warning. No arg shows current.") -@click.option('--curve-interpolation', type=click.Choice(['smooth', 'discrete']), required=False, is_flag=False, flag_value='show', help="Curve interpolation mode. No arg shows current.") -@click.pass_context -def settings(ctx, wait_time, watchdog, ma_window, bypass_warning, curve_interpolation): - """Alias for options""" - ctx.invoke(options, wait_time=wait_time, watchdog=watchdog, ma_window=ma_window, bypass_warning=bypass_warning, curve_interpolation=curve_interpolation) - -@cli.command() -def license(): - """Show license""" - try: - with open(OMEN_FAN_DIR / "LICENSE.md", "r") as f: - content = f.read() - click.echo(content) - except Exception as e: - click.echo("This program is MIT Licensed.") - click.echo("You should have received a copy of the full license text with this program.") - click.echo(f"\n(Error loading LICENSE.md: {e})") - -@cli.command() -def about(): - """Show about information""" - click.echo("HP Omen Fan Control") - click.echo("Version 1.0") - click.echo("Copyright © 2026 Arfelious") - click.echo("\nCustom fan control implementation for HP Omen laptops on Linux.") - -@cli.command() -def acknowledgements(): - """Show acknowledgements""" - click.echo("\nAcknowledgements:\n") - click.echo("Probes:") - click.echo(" https://github.com/alou-S/omen-fan/blob/main/docs/probes.md") - click.echo("\nLinux 6.20 Kernel HP-WMI Driver:") - click.echo(" https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/commit/?h=for-next&id=46be1453e6e61884b4840a768d1e8ffaf01a4c1c") - click.echo("") - -if __name__ == '__main__': - if len(sys.argv) == 1: - cli.main(['--help']) - else: - cli() diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..d197387 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,46 @@ +[project] +name = "omen-fan-control" +version = "1.0.0" +description = "Fan control for HP Omen Max, Victus and Omen laptops on Linux" +readme = "README.md" +license = { text = "GPL-3.0-or-later" } +authors = [{ name = "Arfelious" }] +requires-python = ">=3.10" +dependencies = [ + "click>=8.0", + "PyQt6>=6.4", +] + +[project.optional-dependencies] +dev = [ + "ruff>=0.1", + "build>=1.0", +] + +[project.scripts] +omen-fan-control = "omen_fan_control.cli:main" +omen-fan-control-gui = "omen_fan_control.gui:main" + +[project.urls] +Homepage = "https://github.com/arfelious/omen-fan-control" +Repository = "https://github.com/arfelious/omen-fan-control" + +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[tool.hatch.build.targets.wheel] +packages = ["src/omen_fan_control"] + +[tool.hatch.build.targets.sdist] +include = ["/src", "/README.md", "/LICENSE.md"] + +[dependency-groups] +dev = [ + "ruff>=0.1", + "build>=1.0", +] + +[tool.ruff] +line-length = 120 +target-version = "py310" diff --git a/src/omen_fan_control/__init__.py b/src/omen_fan_control/__init__.py new file mode 100644 index 0000000..64ee953 --- /dev/null +++ b/src/omen_fan_control/__init__.py @@ -0,0 +1,31 @@ +# Omen Fan Control - HP Omen/Victus fan control on Linux +# Copyright (C) 2026 arfelious +# SPDX-License-Identifier: GPL-3.0-or-later + +from pathlib import Path + +__version__ = "1.0.0" + + +def get_data_dir() -> Path: + """Root directory for driver sources, assets, and LICENSE (for installs).""" + env = __import__("os").environ.get("OMEN_FAN_CONTROL_DIR") + if env: + return Path(env).resolve() + return Path(__file__).parent.resolve() / "data" + + +def get_driver_dir() -> Path: + """Directory containing hp-wmi.c, Makefile, install_driver.sh, dkms.conf, hooks.""" + data = get_data_dir() + driver = data / "driver" + return driver if driver.exists() else data + + +def get_assets_dir() -> Path: + """Directory containing logo and other GUI assets.""" + return get_data_dir() / "assets" + + +# Backward compatibility: driver dir is used as OMEN_FAN_DIR in logic (cwd for make/install) +OMEN_FAN_DIR = get_driver_dir() diff --git a/src/omen_fan_control/cli.py b/src/omen_fan_control/cli.py new file mode 100644 index 0000000..98ba1a3 --- /dev/null +++ b/src/omen_fan_control/cli.py @@ -0,0 +1,569 @@ +# Omen Fan Control CLI +# Copyright (C) 2026 arfelious +# SPDX-License-Identifier: GPL-3.0-or-later + +import os +import sys +from pathlib import Path + +import click + +from . import get_data_dir +from .logic import FanController + + +@click.group() +@click.option("--config", type=click.Path(), help="Path to custom config file") +@click.option("--help-extra", is_flag=True, help="Show extra/advanced commands help") +@click.pass_context +def cli(ctx, config, help_extra): + """HP Omen Fan Control CLI""" + if help_extra: + click.echo("Extra / Advanced Commands:") + click.echo(" disable-bios Disable BIOS fan control (writes to EC)") + click.echo(" enable-bios Enable BIOS fan control (writes to EC)") + click.echo("\n Note: Disabling BIOS control is usually unnecessary as the driver handles overrides.") + ctx.exit() + ctx.ensure_object(dict) + ctx.obj["config_path"] = config + controller = FanController(config_path=config) + if os.geteuid() != 0 and not controller.config.get("bypass_root_warning", False): + click.echo(click.style("WARNING: Running without root privileges.", fg="yellow")) + click.echo(click.style("Most commands require root to function correctly.", fg="yellow")) + click.echo(click.style("Use 'omen-fan-control options' to set bypass_root_warning in config to hide this.", dim=True)) + click.echo("", err=True) + if not controller.config.get("bypass_warning", False): + status, board = controller.check_board_support() + if status == "UNSUPPORTED": + click.echo(click.style(f"WARNING: Your board '{board}' is not in the known compatible list.", fg="red")) + click.echo(click.style("Using this tool could potentially cause system instability.", fg="red")) + click.echo("To bypass this warning, set 'bypass_warning' to true in config or toggle in GUI.") + elif status == "POSSIBLY_SUPPORTED" and not controller.config.get("enable_experimental", False): + click.echo(click.style(f"NOTE: Your board '{board}' is valid for experimental support.", fg="yellow")) + click.echo(click.style("Community patches suggest it uses the Omen thermal path.", fg="yellow")) + click.echo("You can enable experimental support in the GUI Settings or by editing config.json:") + click.echo(' "enable_experimental": true, "thermal_profile": "omen" (or victus/victus_s)') + click.echo("") + + +def get_controller(): + ctx = click.get_current_context() + config_path = ctx.obj.get("config_path") if ctx.obj else None + return FanController(config_path=config_path) + + +@cli.command() +def calibrate(): + """Run fan calibration to determine max RPM.""" + controller = get_controller() + if click.confirm("This will spin fans at max speed for calibration. Continue?"): + prev_mode = controller.config.get("mode", "auto") + controller.config["mode"] = "calibration" + controller.save_config() + try: + gen = controller.calibrate() + max_rpm = 0 + try: + while True: + progress = next(gen) + click.echo(f"Calibrating... {progress}%", nl=False) + click.echo("\r", nl=False) + except StopIteration as e: + max_rpm = e.value + click.echo(f"\nCalibration finished. Max RPM: {max_rpm}") + finally: + controller.config["mode"] = prev_mode + controller.save_config() + + +@cli.command() +@click.argument("install_type", required=False) +@click.option("--temp", is_flag=True, help="Legacy: Install temporarily") +@click.option("--perm", is_flag=True, help="Legacy: Install permanently") +@click.option("--restore", is_flag=True, help="Legacy: Restore original") +def install_patch(install_type, temp, perm, restore): + """ + Install the fan driver patch or restore original. + INSTALL_TYPE: t|temp|temporary, p|perm|permanent, r|restore + """ + controller = get_controller() + mode = None + if install_type: + install_type = install_type.lower() + if install_type in ("t", "temp", "temporary"): + mode = "temp" + elif install_type in ("p", "perm", "permanent"): + mode = "perm" + elif install_type in ("r", "restore"): + mode = "restore" + if not mode: + if temp: + mode = "temp" + elif perm: + mode = "perm" + elif restore: + mode = "restore" + if not mode: + click.echo("Please specify: t (temp), p (perm), or r (restore). Example: omen-fan-control install-patch permanent") + return + if mode == "temp": + click.echo("Installing temporary driver...") + success, msg = controller.install_driver_temp() + if not success and msg == "PWM_DETECTED": + itype = controller.check_install_type() + msg_add = "\n(The current installation may be temporary)" if itype == "temporary" else "" + if click.confirm(f"Driver seems to be already active/installed.{msg_add}\nForce re-install?"): + success, msg = controller.install_driver_temp(force=True) + click.echo(msg) + if not success: + sys.exit(1) + elif mode == "perm": + click.echo("Installing permanent driver...") + success, msg = controller.install_driver_perm() + if not success and msg == "PWM_DETECTED": + itype = controller.check_install_type() + msg_add = "\n(The current installation may be temporary)" if itype == "temporary" else "" + if click.confirm(f"Driver seems to be already active/installed.{msg_add}\nForce re-install?"): + success, msg = controller.install_driver_perm(force=True) + click.echo(msg) + if not success: + sys.exit(1) + elif mode == "restore": + click.echo("Restoring original driver...") + success, msg = controller.restore_driver() + click.echo(msg) + if not success: + sys.exit(1) + + +@cli.command() +@click.option("--mode", type=click.Choice(["auto", "max", "manual", "curve", "last"]), help="Fan mode. 'last' loads from config.") +@click.option("--value", required=False, help="Manual: 0-255 (PWM) or 0-100% (e.g. '50%')") +@click.option("--curve-csv", required=False, type=click.Path(exists=True), help="CSV for curve (temp,percent)") +@click.argument("action", required=False) +def fan_control(mode, value, curve_csv, action): + """Control fan mode and speed. E.g. fan-control --mode auto; fan-control set (apply last).""" + if mode is None: + if curve_csv: + mode = "curve" + elif action == "set": + mode = "last" + else: + ctx = click.get_current_context() + click.echo(ctx.get_help()) + ctx.exit() + controller = get_controller() + default_conf = Path("/etc/omen-fan-control/config.json") + if controller.is_service_running() and controller.config_path.resolve() != default_conf.resolve(): + click.echo(click.style("WARNING: Background service is active using system config.", fg="yellow")) + click.echo(click.style(f"It may overwrite changes from {controller.config_path.name}.", fg="yellow")) + click.echo("Suggestion: Stop the service before testing custom configs.\n") + if mode == "last": + mode = controller.config.get("mode", "auto") + click.echo(f"Applying last saved mode: {mode.upper()}") + if mode == "auto": + controller.set_fan_mode("auto") + click.echo("Fan set to AUTO.") + elif mode == "max": + controller.set_fan_mode("max") + click.echo("Fan set to MAX.") + elif mode == "manual": + if not (controller.pwm1_path and controller.pwm1_path.exists()): + click.echo("Error: Manual mode requires the kernel driver patch. Run 'omen-fan-control install-patch perm'.") + sys.exit(1) + if value is None: + click.echo("Please specify --value (0-255 or 0-100%) for manual mode") + return + try: + val_str = str(value).strip() + if val_str.endswith("%"): + percent = int(val_str[:-1]) + if not (0 <= percent <= 100): + click.echo("Error: Percentage must be 0-100.") + return + pwm_val = int(round(percent / 100 * 255)) + click.echo(f"Setting speed to {percent}% (PWM: {pwm_val})") + else: + pwm_val = int(val_str) + if not (0 <= pwm_val <= 255): + click.echo("Error: PWM value must be 0-255.") + return + click.echo(f"Setting PWM to {pwm_val}") + controller.config["mode"] = "manual" + controller.config["manual_pwm"] = pwm_val + controller.save_config() + controller.set_fan_pwm(pwm_val) + except ValueError: + click.echo(f"Error: Invalid value '{value}'. Use 0-255 or '50%'.") + return + elif mode == "curve": + if not (controller.pwm1_path and controller.pwm1_path.exists()): + click.echo("Error: Curve mode requires the kernel driver patch. Run 'omen-fan-control install-patch perm'.") + sys.exit(1) + if curve_csv: + points = [] + try: + with open(curve_csv, "r") as f: + for line in f: + line = line.strip() + if not line or line.startswith("#") or "," not in line: + continue + parts = line.split(",") + if len(parts) >= 2: + temp, speed = int(parts[0].strip()), int(parts[1].strip()) + if not (0 <= speed <= 100): + click.echo(f"Error: Speed {speed} must be 0-100%.") + return + points.append([temp, speed]) + if not points: + click.echo("Error: No valid points in CSV.") + return + points.sort(key=lambda x: x[0]) + controller.config["curve"] = points + click.echo(f"Loaded {len(points)} points from CSV.") + except Exception as e: + click.echo(f"Error reading CSV: {e}") + return + controller.config["mode"] = "curve" + controller.save_config() + click.echo("Curve mode enabled in config.") + if not controller.is_service_installed(): + click.echo("WARNING: Background service is NOT installed. Curve mode needs the service.") + click.echo(" sudo systemctl start omen-fan-control.service or omen-fan-control serve") + else: + click.echo("Service should pick up the change automatically.") + + +@cli.command() +def serve(): + """Run the fan control daemon (foreground). Used by systemd service.""" + import time + controller = get_controller() + click.echo("Starting Omen Fan Control Daemon...") + ma_window = controller.config.get("ma_window", 5) + temp_history = [] + watchdog_interval = controller.config.get("watchdog_interval", 90) + last_watchdog_time = time.time() + hysteresis_start_time = None + last_config_mtime = 0 + while True: + try: + try: + current_mtime = controller.config_path.stat().st_mtime + if current_mtime > last_config_mtime: + controller.config = controller.load_config() + last_config_mtime = current_mtime + except Exception: + pass + mode = controller.config.get("mode", "auto") + if mode == "calibration": + time.sleep(1) + continue + if time.time() - last_watchdog_time > watchdog_interval: + last_watchdog_time = time.time() + current_temp = controller.get_cpu_temp() + temp_history.append(current_temp) + if len(temp_history) > ma_window: + temp_history.pop(0) + avg_temp = sum(temp_history) / len(temp_history) + if mode == "curve": + target_pwm = controller.calculate_target_pwm(avg_temp) + if target_pwm is not None: + current_rpm = controller.get_fan_speed() + max_rpm = controller.config.get("fan_max", 0) + should_apply = True + if max_rpm > 0: + target_rpm = (target_pwm / 255) * max_rpm + diff = abs(target_rpm - current_rpm) + if diff <= 200: + if hysteresis_start_time is None: + hysteresis_start_time = time.time() + should_apply = time.time() - hysteresis_start_time > 60 + else: + hysteresis_start_time = None + if should_apply: + controller.set_fan_pwm(target_pwm) + hysteresis_start_time = None + elif mode == "manual": + manual_val = controller.config.get("manual_pwm", -1) + if manual_val >= 0: + controller.set_fan_pwm(manual_val) + elif mode == "max": + controller.set_fan_mode("max") + elif mode == "auto": + controller.set_fan_mode("auto") + time.sleep(2) + except KeyboardInterrupt: + click.echo("Stopping daemon...") + break + except Exception as e: + click.echo(f"Error in daemon loop: {e}") + time.sleep(5) + + +@cli.command() +@click.argument("duration", required=True) +def stress(duration): + """Run CPU stress test. DURATION: 30s, 1m, 5m, 1h.""" + import time + controller = get_controller() + try: + s = duration.lower().strip() + if s.endswith("s"): + seconds = int(s[:-1]) + elif s.endswith("m"): + seconds = int(s[:-1]) * 60 + elif s.endswith("h"): + seconds = int(s[:-1]) * 3600 + else: + seconds = int(s) + if seconds <= 0: + click.echo("Error: Duration must be positive.") + return + except ValueError: + click.echo(f"Error: Invalid duration '{duration}'. Use 30s, 1m, etc.") + return + click.echo(f"Starting CPU Stress Test for {seconds}s... Press Ctrl+C to stop.") + if controller.start_stress_test(seconds): + try: + start = time.time() + while time.time() - start < seconds: + click.echo(f"Time remaining: {seconds - int(time.time() - start)}s ", nl=False) + click.echo("\r", nl=False) + time.sleep(1) + except KeyboardInterrupt: + click.echo("\nStress test cancelled.") + finally: + controller.stop_stress_test() + click.echo("\nStress test stopped.") + else: + click.echo("Failed to start stress test.") + + +@cli.command() +@click.option("--wait-time", type=int, required=False, is_flag=False, flag_value=-1) +@click.option("--watchdog", type=int, required=False, is_flag=False, flag_value=-1) +@click.option("--ma-window", type=int, required=False, is_flag=False, flag_value=-1) +@click.option("--bypass-warning", type=click.Choice(["on", "off"]), required=False, is_flag=False, flag_value="show") +@click.option("--curve-interpolation", type=click.Choice(["smooth", "discrete"]), required=False, is_flag=False, flag_value="show") +@click.option("--enable-experimental", type=click.Choice(["on", "off"]), required=False, is_flag=False, flag_value="show") +@click.option("--thermal-profile", type=click.Choice(["omen", "victus", "victus_s"]), required=False, is_flag=False, flag_value="show") +def options(wait_time, watchdog, ma_window, bypass_warning, curve_interpolation, enable_experimental, thermal_profile): + """Configure or view options. Run with no args to view all.""" + controller = get_controller() + opts = [wait_time, watchdog, ma_window, bypass_warning, curve_interpolation, enable_experimental, thermal_profile] + if all(x is None for x in opts): + wt = controller.config.get("calibration_wait", 5) + wd = controller.config.get("watchdog_interval", 90) + mw = controller.config.get("ma_window", 5) + bp = controller.config.get("bypass_patch_warning", False) + ci = controller.config.get("curve_interpolation", "smooth") + ee = controller.config.get("enable_experimental", False) + tp = controller.config.get("thermal_profile", "omen") + click.echo("Current Configuration:") + click.echo(f" Calibration Wait Time: {wt}s \t--wait-time") + click.echo(f" Watchdog Interval: {wd}s \t--watchdog") + click.echo(f" MA Window (Smoothing): {mw} \t--ma-window") + click.echo(f" Bypass Warning: {'On' if bp else 'Off'} \t--bypass-warning") + click.echo(f" Curve Interpolation: {ci} \t--curve-interpolation") + click.echo(f" Experimental Support: {'On' if ee else 'Off'} \t--enable-experimental") + click.echo(f" Thermal Profile: {tp} \t--thermal-profile") + return + changed = False + if wait_time is not None: + if wait_time == -1: + click.echo(f"Current Calibration Wait Time: {controller.config.get('calibration_wait', 5)}s") + elif wait_time > 0: + controller.config["calibration_wait"] = wait_time + changed = True + click.echo(f"Calibration wait time set to {wait_time}s") + if watchdog is not None: + if watchdog == -1: + click.echo(f"Current Watchdog Interval: {controller.config.get('watchdog_interval', 90)}s") + elif watchdog > 0: + controller.config["watchdog_interval"] = watchdog + changed = True + click.echo(f"Watchdog interval set to {watchdog}s") + if ma_window is not None: + if ma_window == -1: + click.echo(f"Current MA Window: {controller.config.get('ma_window', 5)}") + elif ma_window > 0: + controller.config["ma_window"] = ma_window + changed = True + click.echo(f"MA Window set to {ma_window}") + if bypass_warning is not None: + if bypass_warning == "show": + click.echo(f"Current Bypass Warning: {'On' if controller.config.get('bypass_patch_warning', False) else 'Off'}") + else: + controller.config["bypass_patch_warning"] = bypass_warning == "on" + changed = True + click.echo(f"Bypass Warning set to {'On' if controller.config['bypass_patch_warning'] else 'Off'}") + if enable_experimental is not None: + if enable_experimental == "show": + click.echo(f"Current Experimental Support: {'On' if controller.config.get('enable_experimental', False) else 'Off'}") + else: + controller.config["enable_experimental"] = enable_experimental == "on" + changed = True + click.echo(f"Experimental Support set to {'On' if controller.config['enable_experimental'] else 'Off'}") + if thermal_profile is not None: + if thermal_profile == "show": + click.echo(f"Current Thermal Profile: {controller.config.get('thermal_profile', 'omen')}") + else: + controller.config["thermal_profile"] = thermal_profile + changed = True + click.echo(f"Thermal Profile set to {thermal_profile}") + if curve_interpolation is not None: + if curve_interpolation == "show": + click.echo(f"Current Interpolation: {controller.config.get('curve_interpolation', 'smooth')}") + else: + controller.config["curve_interpolation"] = curve_interpolation + changed = True + click.echo(f"Curve Interpolation set to {curve_interpolation}") + if changed: + controller.save_config() + + +@cli.group() +def service(): + """Manage background service""" + pass + + +@service.command(name="install") +def install_service_cmd(): + """Install and enable the background service""" + controller = get_controller() + click.echo("Installing background service...") + success, msg = controller.create_service() + click.echo(msg) + + +@service.command(name="remove") +def remove_service_cmd(): + """Stop and remove the background service""" + controller = get_controller() + click.echo("Removing background service...") + success, msg = controller.remove_service() + click.echo(msg) + + +@service.command(name="status") +def service_status_cmd(): + """Check service status""" + controller = get_controller() + click.echo(f"Service Installed: {'Yes' if controller.is_service_installed() else 'No'}") + click.echo(f"Service Running: {'Yes' if controller.is_service_running() else 'No'}") + + +@cli.command() +def status(): + """Show system status (Temps, Fan, Service)""" + controller = get_controller() + is_running = controller.is_service_running() + status_str = click.style("RUNNING", fg="green") if is_running else click.style("STOPPED", fg="red") + if not controller.is_service_installed(): + status_str = click.style("NOT INSTALLED", fg="yellow") + click.echo(f"Service Status: {status_str}") + install_type = controller.check_install_type() + type_str = "None" + if install_type == "permanent": + type_str = click.style("Permanent", fg="green") + elif install_type == "temporary": + type_str = click.style("Temporary (Session)", fg="yellow") + click.echo(f"Driver Install: {type_str}") + mode = "Unknown" + try: + enable = controller.read_sys_file(controller.pwm1_enable_path) + if enable == "0": + mode = "Max (0)" + elif enable == "1": + if controller.is_service_running(): + cm = controller.config.get("mode", "manual") + mode = "Curve (Service)" if cm == "curve" else f"Manual Fixed ({controller.config.get('manual_pwm', 0)})" + else: + mode = "Manual (1)" + elif enable == "2": + mode = "Auto (2)" + else: + mode = f"Unknown ({enable})" + except Exception: + mode = "N/A" + click.echo(f"Driver Mode: {mode}") + click.echo(f"Fan Speed: {controller.get_fan_speed()} RPM") + click.echo(f"CPU Package Temp: {controller.get_cpu_temp()}°C") + click.echo("\nCore Temperatures:") + for label, temp in controller.get_all_core_temps() or []: + click.echo(f" {label:<15} {temp}°C") + + +@cli.command(hidden=True) +def disable_bios(): + """Disable BIOS fan control (Enable Manual Mode)""" + controller = get_controller() + if click.confirm("This will write to EC registers to disable BIOS fan control. Continue?"): + if controller.set_bios_control(False): + click.echo("BIOS control disabled (Manual mode enabled).") + else: + click.echo("Failed to disable BIOS control.") + + +@cli.command(hidden=True) +def enable_bios(): + """Enable BIOS fan control""" + controller = get_controller() + if controller.set_bios_control(True): + click.echo("BIOS control enabled.") + else: + click.echo("Failed to enable BIOS control.") + + +@cli.command() +@click.option("--wait-time", type=int, required=False, is_flag=False, flag_value=-1) +@click.option("--watchdog", type=int, required=False, is_flag=False, flag_value=-1) +@click.option("--ma-window", type=int, required=False, is_flag=False, flag_value=-1) +@click.option("--bypass-warning", type=click.Choice(["on", "off"]), required=False, is_flag=False, flag_value="show") +@click.option("--curve-interpolation", type=click.Choice(["smooth", "discrete"]), required=False, is_flag=False, flag_value="show") +@click.pass_context +def settings(ctx, wait_time, watchdog, ma_window, bypass_warning, curve_interpolation): + """Alias for options""" + ctx.invoke(options, wait_time=wait_time, watchdog=watchdog, ma_window=ma_window, bypass_warning=bypass_warning, curve_interpolation=curve_interpolation) + + +@cli.command() +def license(): + """Show license""" + license_path = get_data_dir() / "LICENSE.md" + try: + click.echo(license_path.read_text()) + except Exception as e: + click.echo("This program is GPL-3.0-or-later licensed.") + click.echo(f"(Error loading LICENSE: {e})") + + +@cli.command() +def about(): + """Show about information""" + click.echo("HP Omen Fan Control") + click.echo("Version 1.0") + click.echo("Copyright © 2026 Arfelious") + click.echo("\nCustom fan control for HP Omen laptops on Linux.") + + +@cli.command() +def acknowledgements(): + """Show acknowledgements""" + click.echo("\nAcknowledgements:\n") + click.echo("Probes: https://github.com/alou-S/omen-fan/blob/main/docs/probes.md") + click.echo("Linux 6.20 HP-WMI: https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/commit/?h=for-next&id=46be1453e6e61884b4840a768d1e8ffaf01a4c1c") + click.echo("") + + +def main(): + if len(sys.argv) == 1: + cli.main(["--help"]) + else: + cli() + + +if __name__ == "__main__": + main() diff --git a/src/omen_fan_control/data/LICENSE.md b/src/omen_fan_control/data/LICENSE.md new file mode 100644 index 0000000..b8991b1 --- /dev/null +++ b/src/omen_fan_control/data/LICENSE.md @@ -0,0 +1,187 @@ +GNU GENERAL PUBLIC LICENSE + +Version 3, 29 June 2007 + +Copyright © 2007 Free Software Foundation, Inc. + +Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. +Preamble + +The GNU General Public License is a free, copyleft license for software and other kinds of works. + +The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. + +When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. + +To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. + +For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. + +Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. + +For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. + +Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. + +Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. + +The precise terms and conditions for copying, distribution and modification follow. +TERMS AND CONDITIONS +0. Definitions. + +“This License” refers to version 3 of the GNU General Public License. + +“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. + +“The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations. + +To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work. + +A “covered work” means either the unmodified Program or a work based on the Program. + +To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. + +To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. + +An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. +1. Source Code. + +The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work. + +A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. + +The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. + +The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. + +The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. + +The Corresponding Source for a work in source code form is that same work. +2. Basic Permissions. + +All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. + +You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. + +Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. +3. Protecting Users' Legal Rights From Anti-Circumvention Law. + +No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. + +When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. +4. Conveying Verbatim Copies. + +You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. + +You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. +5. Conveying Modified Source Versions. + +You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified it, and giving a relevant date. + b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”. + c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. + d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. + +A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. +6. Conveying Non-Source Forms. + +You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: + + a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. + b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. + c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. + d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. + e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. + +A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. + +A “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. + +“Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. + +If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). + +The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. + +Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. +7. Additional Terms. + +“Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. + +When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. + +Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or + b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or + c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or + d) Limiting the use for publicity purposes of names of licensors or authors of the material; or + e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or + f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. + +All other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. + +If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. + +Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. +8. Termination. + +You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). + +However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. + +Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. + +Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. +9. Acceptance Not Required for Having Copies. + +You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. +10. Automatic Licensing of Downstream Recipients. + +Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. + +An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. + +You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. +11. Patents. + +A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's “contributor version”. + +A contributor's “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. + +Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. + +In the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. + +If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. + +If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. + +A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. + +Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. +12. No Surrender of Others' Freedom. + +If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. +13. Use with the GNU Affero General Public License. + +Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. +14. Revised Versions of this License. + +The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. + +If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. + +Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. +15. Disclaimer of Warranty. + +THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. +16. Limitation of Liability. + +IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +17. Interpretation of Sections 15 and 16. + +If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. \ No newline at end of file diff --git a/Makefile b/src/omen_fan_control/data/driver/Makefile similarity index 100% rename from Makefile rename to src/omen_fan_control/data/driver/Makefile diff --git a/dkms.conf b/src/omen_fan_control/data/driver/dkms.conf similarity index 100% rename from dkms.conf rename to src/omen_fan_control/data/driver/dkms.conf diff --git a/hooks/90-hp-wmi-omen.hook b/src/omen_fan_control/data/driver/hooks/90-hp-wmi-omen.hook similarity index 100% rename from hooks/90-hp-wmi-omen.hook rename to src/omen_fan_control/data/driver/hooks/90-hp-wmi-omen.hook diff --git a/hooks/99-hp-wmi-omen.install b/src/omen_fan_control/data/driver/hooks/99-hp-wmi-omen.install similarity index 100% rename from hooks/99-hp-wmi-omen.install rename to src/omen_fan_control/data/driver/hooks/99-hp-wmi-omen.install diff --git a/hooks/zz-hp-wmi-omen b/src/omen_fan_control/data/driver/hooks/zz-hp-wmi-omen similarity index 100% rename from hooks/zz-hp-wmi-omen rename to src/omen_fan_control/data/driver/hooks/zz-hp-wmi-omen diff --git a/hp-wmi.c b/src/omen_fan_control/data/driver/hp-wmi.c similarity index 100% rename from hp-wmi.c rename to src/omen_fan_control/data/driver/hp-wmi.c diff --git a/hp-wmi.c.orig b/src/omen_fan_control/data/driver/hp-wmi.c.orig similarity index 100% rename from hp-wmi.c.orig rename to src/omen_fan_control/data/driver/hp-wmi.c.orig diff --git a/install_driver.sh b/src/omen_fan_control/data/driver/install_driver.sh similarity index 100% rename from install_driver.sh rename to src/omen_fan_control/data/driver/install_driver.sh diff --git a/fan_curve_widget.py b/src/omen_fan_control/fan_curve_widget.py similarity index 95% rename from fan_curve_widget.py rename to src/omen_fan_control/fan_curve_widget.py index fbde3b0..91b4977 100644 --- a/fan_curve_widget.py +++ b/src/omen_fan_control/fan_curve_widget.py @@ -191,7 +191,13 @@ def get_points(self): return [(p.x(), p.y()) for p in self.points] def set_points(self, points): - self.points = [QPointF(x, y) for x, y in points] + if points is None: + self.points = [ + QPointF(30, 0), QPointF(40, 10), QPointF(50, 25), QPointF(60, 40), + QPointF(70, 55), QPointF(80, 70), QPointF(90, 85), QPointF(95, 100), QPointF(105, 100), + ] + else: + self.points = [QPointF(x, y) for x, y in points] if self.points: last = self.points[-1] if last.x() != self.max_temp: diff --git a/omen_gui.py b/src/omen_fan_control/gui.py similarity index 99% rename from omen_gui.py rename to src/omen_fan_control/gui.py index ba49c84..391fa8e 100644 --- a/omen_gui.py +++ b/src/omen_fan_control/gui.py @@ -9,8 +9,9 @@ QProgressBar, QScrollArea, QSizePolicy, QListView, QTextEdit, QStyle, QStyledItemDelegate, QCheckBox) from PyQt6.QtCore import Qt, QTimer, QThread, pyqtSignal, QSize, QPoint from PyQt6.QtGui import QFont, QIcon, QAction, QColor, QPainter, QBrush, QPen -from omen_logic import FanController, OMEN_FAN_DIR -from fan_curve_widget import FanCurveEditor +from . import get_assets_dir, get_data_dir +from .logic import FanController +from .fan_curve_widget import FanCurveEditor class WorkerThread(QThread): finished = pyqtSignal(object) @@ -190,7 +191,7 @@ def __init__(self): self.resize(900, 600) # Set Window Icon - icon_path = OMEN_FAN_DIR / "assets" / "logo_test.png" + icon_path = get_assets_dir() / "logo_test.png" if icon_path.exists(): self.setWindowIcon(QIcon(str(icon_path))) @@ -932,7 +933,7 @@ def init_about_page(self): license_text.setReadOnly(True) try: - with open(OMEN_FAN_DIR / "LICENSE.md", "r") as f: + with open(get_data_dir() / "LICENSE.md", "r") as f: content = f.read() except Exception as e: content = (f"This program is free software: you can redistribute it and/or modify\n" @@ -1387,18 +1388,18 @@ def closeEvent(self, event): self.rpm_timer.stop() event.accept() -if __name__ == "__main__": +def main(): import signal signal.signal(signal.SIGINT, signal.SIG_DFL) - app = QApplication(sys.argv) app.setStyle("Windows") - - # Set App Icon - icon_path = OMEN_FAN_DIR / "assets" / "logo.png" + icon_path = get_assets_dir() / "logo.png" if icon_path.exists(): app.setWindowIcon(QIcon(str(icon_path))) - window = MainWindow() window.show() sys.exit(app.exec()) + + +if __name__ == "__main__": + main() diff --git a/omen_logic.py b/src/omen_fan_control/logic.py similarity index 56% rename from omen_logic.py rename to src/omen_fan_control/logic.py index 0406adf..2c568b7 100644 --- a/omen_logic.py +++ b/src/omen_fan_control/logic.py @@ -1,33 +1,25 @@ -import os -# Omen Fan Control -# Control your HP Laptop's fans in Linux +# Omen Fan Control - Core logic # Copyright (C) 2026 arfelious -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . +# SPDX-License-Identifier: GPL-3.0-or-later import glob import json -import time import math +import os import shutil import subprocess +import sys +import time from pathlib import Path +from . import OMEN_FAN_DIR + +# Subdir containing hp-wmi.c and Makefile (same layout as DKMS package src/hp-wmi-omen) +DRIVER_BUILD_DIR = OMEN_FAN_DIR / "hp-wmi-omen" + # Constants HWMON_PATH_PATTERN = "/sys/devices/platform/hp-wmi/hwmon/*/" THERMAL_ZONE_PATH = "/sys/class/thermal/thermal_zone0/temp" -# Determine config path based on permissions if os.geteuid() == 0: CONFIG_DIR = Path("/etc/omen-fan-control") else: @@ -36,7 +28,6 @@ CONFIG_FILE = CONFIG_DIR / "config.json" DEFAULT_CALIBRATION_WAIT = 30 DEFAULT_WATCHDOG_INTERVAL = 90 -OMEN_FAN_DIR = Path(__file__).parent.absolute() CONFIG_VERSION = 1 # Supported Board IDs @@ -50,26 +41,26 @@ "88F7", "88FD", "88FE", "88FF", "8900", "8901", "8902", "8912", "8917", "8918", "8949", "894A", "89EB", "8A15", "8A42", "8BAD", - "8A25", "8BBE", "8BD4", "8BD5", "8C78", "8C99", "8C9C", "8D41" } POSSIBLY_SUPPPORTED_OMEN_BOARDS = { "84DA", "84DB", "84DC", "8574", "8575", "860A", "87B5", "8572", "8573", - "8600", "8601", "8602", "8605", "8606", "8607", "8746", "8747", "8749", - "874A", "8603", "8604", "8748", "886B", "886C", "878A", "878B", "878C", - "88C8", "88CB", "8786", "8787", "8788", "88D1", "88D2", "88F4", "88FD", - "88F5", "88F6", "8A13", "8A14", "8A15", "8A16", "88F7", "88FE", "8A17", - "8A18", "8A19", "8A1A", "8BAD", "8BB0", "88FF", "8900", "8901", "8902", - "8912", "8917", "8918", "8A97", "8A96", "8D2C", "8949", "8A98", "894A", - "8B1D", "89EB", "8A4C", "8A4D", "8A4E", "8A40", "8A41", "8A42", "8A43", - "8A44", "8BA8", "8BA9", "8BAA", "8BAB", "8BAC", "8C76", "8C77", "8C78", - "8BCA", "8BCB", "8BCD", "8BCF", "8C9B", "8BB3", "8BB4", "8C4D", "8C4E", - "8C58", "8C75", "8C74", "8C73", "8CC1", "8CC0", "8CF1", "8CF2", "8CF3", - "8CF4" + "8600", "8601", "8602", "8605", "8606", "8607", "8746", "8747", "8749", + "874A", "8603", "8604", "8748", "886B", "886C", "878A", "878B", "878C", + "88C8", "88CB", "8786", "8787", "8788", "88D1", "88D2", "88F4", "88FD", + "88F5", "88F6", "8A13", "8A14", "8A15", "8A16", "88F7", "88FE", "8A17", + "8A18", "8A19", "8A1A", "8BAD", "8BB0", "88FF", "8900", "8901", "8902", + "8912", "8917", "8918", "8A97", "8A96", "8D2C", "8949", "8A98", "894A", + "8B1D", "89EB", "8A4C", "8A4D", "8A4E", "8A40", "8A41", "8A42", "8A43", + "8A44", "8BA8", "8BA9", "8BAA", "8BAB", "8BAC", "8C76", "8C77", "8C78", + "8BCA", "8BCB", "8BCD", "8BCF", "8C9B", "8BB3", "8BB4", "8C4D", "8C4E", + "8C58", "8C75", "8C74", "8C73", "8CC1", "8CC0", "8CF1", "8CF2", "8CF3", + "8CF4" } + class FanController: def __init__(self, config_path=None): self._find_paths() @@ -77,42 +68,29 @@ def __init__(self, config_path=None): self.config_path = Path(config_path) else: self.config_path = CONFIG_FILE - self.config = self.load_config() def check_board_support(self): - """ - Checks if the current board is in the supported list. - Returns (status, board_name) - status: "SUPPORTED", "POSSIBLY_SUPPORTED", "UNSUPPORTED" - """ - # Return cached if available + """Returns (status, board_name). status: SUPPORTED, POSSIBLY_SUPPORTED, UNSUPPORTED.""" if self.config.get("cached_board_name"): board_name = self.config["cached_board_name"] else: try: with open("/sys/class/dmi/id/board_name", "r") as f: board_name = f.read().strip() - self.config["cached_board_name"] = board_name self.save_config() - except Exception as e: print(f"Error reading board name: {e}") return "UNSUPPORTED", "Unknown" - if board_name in SUPPORTED_BOARDS: return "SUPPORTED", board_name - elif board_name in POSSIBLY_SUPPPORTED_OMEN_BOARDS: + if board_name in POSSIBLY_SUPPPORTED_OMEN_BOARDS: return "POSSIBLY_SUPPORTED", board_name - else: - return "UNSUPPORTED", board_name + return "UNSUPPORTED", board_name def _find_paths(self): - """Finds the correct hwmon paths for fan control.""" - # Find CPU temp path independent of HP WMI self.cpu_temp_path = self._find_cpu_temp_path() - paths = glob.glob(HWMON_PATH_PATTERN) if not paths: self.hwmon_path = None @@ -120,7 +98,6 @@ def _find_paths(self): self.pwm1_path = None self.fan1_input_path = None return - self.hwmon_path = Path(paths[0]) self.pwm1_enable_path = self.hwmon_path / "pwm1_enable" self.pwm1_path = self.hwmon_path / "pwm1" @@ -128,7 +105,6 @@ def _find_paths(self): self.cpu_temp_path = self._find_cpu_temp_path() def _find_cpu_temp_path(self): - """Finds the CPU temperature input file.""" for hwmon in Path("/sys/class/hwmon").glob("hwmon*"): try: name_path = hwmon / "name" @@ -136,23 +112,17 @@ def _find_cpu_temp_path(self): continue with open(name_path, "r") as f: name = f.read().strip() - if name in ["coretemp", "k10temp"]: temp_path = hwmon / "temp1_input" if temp_path.exists(): return temp_path except Exception: continue - - # Fallback to thermal_zone0 if Path("/sys/class/thermal/thermal_zone0/temp").exists(): - return Path("/sys/class/thermal/thermal_zone0/temp") - + return Path("/sys/class/thermal/thermal_zone0/temp") return None - def load_config(self): - """Loads configuration from JSON file.""" defaults = { "version": CONFIG_VERSION, "fan_max": 0, @@ -161,6 +131,7 @@ def load_config(self): "ma_window": 5, "curve": [], "bypass_warning": False, + "bypass_patch_warning": False, "mode": "auto", "manual_pwm": 0, "curve_interpolation": "smooth", @@ -168,35 +139,28 @@ def load_config(self): "enable_experimental": False, "thermal_profile": "omen", "cached_board_name": None, - "debug_experimental_ui": True + "debug_experimental_ui": False, } - if not self.config_path.exists(): return defaults - try: with open(self.config_path, "r") as f: data = json.load(f) - config = defaults.copy() config.update(data) return config - except Exception as e: print(f"Error loading config: {e}") return defaults def save_config(self): - """Saves current configuration to JSON file.""" if self.config_path.parent: - self.config_path.parent.mkdir(parents=True, exist_ok=True) - + self.config_path.parent.mkdir(parents=True, exist_ok=True) self.config["version"] = CONFIG_VERSION with open(self.config_path, "w") as f: json.dump(self.config, f, indent=4) def write_sys_file(self, path, value): - """Helper to write to sysfs files.""" if not path: return try: @@ -208,7 +172,6 @@ def write_sys_file(self, path, value): print(f"Error writing to {path}: {e}") def read_sys_file(self, path): - """Helper to read from sysfs files.""" if not path or not path.exists(): return None try: @@ -219,139 +182,96 @@ def read_sys_file(self, path): return None def get_fan_speed(self): - """Returns current fan speed in RPM.""" val = self.read_sys_file(self.fan1_input_path) - if not val: - print("Failed to read fan speed") - return 0 - return int(val) + return int(val) if val else 0 def get_cpu_temp(self): - """Returns CPU temp in Celsius.""" if self.cpu_temp_path: val = self.read_sys_file(self.cpu_temp_path) return int(val) // 1000 if val else 0 return 0 - def get_all_core_temps(self): - """Returns a list of tuples [(label, temp), ...] sorted by core index.""" core_temps = [] package_temps = [] - if not self.cpu_temp_path: - return [] - + return [] hwmon_dir = self.cpu_temp_path.parent - for f in hwmon_dir.glob("temp*_input"): try: label_file = f.with_name(f.name.replace("input", "label")) - if label_file.exists(): - label = self.read_sys_file(label_file) - else: - label = f.name - + label = self.read_sys_file(label_file) if label_file.exists() else f.name val = self.read_sys_file(f) - if not val: continue + if not val: + continue temp = int(val) // 1000 - if "Core" in label: try: idx = int(label.split()[-1]) core_temps.append((idx, label, temp)) - except: + except Exception: core_temps.append((999, label, temp)) elif "Package" in label: package_temps.append((label, temp)) - except: + except Exception: continue - core_temps.sort(key=lambda x: x[0]) - - params = [] - for p in package_temps: - params.append(p) - + params = list(package_temps) for c in core_temps: params.append((c[1], c[2])) - return params def set_fan_mode(self, mode): - """Sets fan mode: 'max', 'auto', or 'manual'.""" - if mode == 'max': + if mode == "max": self.write_sys_file(self.pwm1_enable_path, 0) - elif mode == 'auto': + elif mode == "auto": self.write_sys_file(self.pwm1_enable_path, 2) def set_fan_pwm(self, value): - """Sets fan speed (0-255). Ensures manual mode (pwm1_enable=1).""" - # Ensure we are in manual mode current_enable = self.read_sys_file(self.pwm1_enable_path) if current_enable != "1": self.write_sys_file(self.pwm1_enable_path, 1) - - # value should be 0-255 self.write_sys_file(self.pwm1_path, str(int(value))) def calculate_target_pwm(self, current_temp): - """Calculates target PWM (0-255) based on curve and temperature.""" curve = self.config.get("curve", []) - if not curve: + if not curve: return None - curve = sorted(curve, key=lambda p: p[0]) - target_speed_percent = 0 - if current_temp <= curve[0][0]: target_speed_percent = curve[0][1] elif current_temp >= curve[-1][0]: target_speed_percent = curve[-1][1] else: for i in range(len(curve) - 1): - p1 = curve[i] - p2 = curve[i+1] + p1, p2 = curve[i], curve[i + 1] if p1[0] <= current_temp <= p2[0]: interp_mode = self.config.get("curve_interpolation", "smooth") - if interp_mode == "discrete": target_speed_percent = p1[1] else: denom = p2[0] - p1[0] - if denom == 0: - target_speed_percent = p2[1] - else: - ratio = (current_temp - p1[0]) / denom - target_speed_percent = p1[1] + ratio * (p2[1] - p1[1]) + target_speed_percent = p2[1] if denom == 0 else p1[1] + (current_temp - p1[0]) / denom * (p2[1] - p1[1]) break - return int(round(target_speed_percent / 100 * 255)) def calibrate(self): - """Runs calibration routine. Yields progress (0-100), returns max RPM.""" print("Starting calibration...") - try: prev_enable = self.read_sys_file(self.pwm1_enable_path) or "2" prev_pwm = self.read_sys_file(self.pwm1_path) or "0" - except: - prev_enable = "2" - prev_pwm = "0" - - self.set_fan_mode('max') - + except Exception: + prev_enable, prev_pwm = "2", "0" + self.set_fan_mode("max") wait_time = self.config.get("calibration_wait", DEFAULT_CALIBRATION_WAIT) steps = 10 for i in range(steps): - time.sleep(wait_time / steps) - yield int((i + 1) / steps * 100) - + time.sleep(wait_time / steps) + yield int((i + 1) / steps * 100) max_rpm = self.get_fan_speed() self.config["fan_max"] = max_rpm self.save_config() - try: if prev_enable: self.write_sys_file(self.pwm1_enable_path, prev_enable) @@ -359,176 +279,117 @@ def calibrate(self): self.write_sys_file(self.pwm1_path, prev_pwm) except Exception as e: print(f"Error restoring fan state: {e}") - return max_rpm def _patch_driver_source(self, fan_max): - """Patches hp-wmi.c with the max rpm value and experimental boards if enabled.""" - orig_file = OMEN_FAN_DIR / "hp-wmi.c.orig" - target_file = OMEN_FAN_DIR / "hp-wmi.c" - + orig_file = DRIVER_BUILD_DIR / "hp-wmi.c.orig" + target_file = DRIVER_BUILD_DIR / "hp-wmi.c" if not orig_file.exists(): if target_file.exists(): shutil.copy(target_file, orig_file) else: return False, "Error: hp-wmi.c not found." - - # Read orig content with open(orig_file, "r") as f: content = f.read() - - # 1. Patch Max RPM max_rpm_val = math.floor(fan_max / 100) - new_define = f"#define OMEN_MAX_RPM {max_rpm_val}" - content = content.replace("#define OMEN_MAX_RPM 60", new_define) - - # 2. Patch Experimental Support if enabled + content = content.replace("#define OMEN_MAX_RPM 60", f"#define OMEN_MAX_RPM {max_rpm_val}") if self.config.get("enable_experimental", False): - board_name = self.config.get("cached_board_name") - if not board_name: - # Try to get it if not cached - _, board_name = self.check_board_support() - + board_name = self.config.get("cached_board_name") or self.check_board_support()[1] if board_name and board_name != "Unknown": profile = self.config.get("thermal_profile", "omen") - - target_array = "omen_thermal_profile_boards" - if profile == "victus": - target_array = "victus_thermal_profile_boards" - elif profile == "victus_s": - target_array = "victus_s_thermal_profile_boards" - + target_array = {"victus": "victus_thermal_profile_boards", "victus_s": "victus_s_thermal_profile_boards"}.get(profile, "omen_thermal_profile_boards") start_idx = content.find(f"{target_array}[]") if start_idx != -1: - # Find closing brace after start_idx end_idx = content.find("};", start_idx) if end_idx != -1: - # Check if board is already in there - segment = content[start_idx:end_idx] - if f'"{board_name}"' not in segment: - if target_array == "victus_s_thermal_profile_boards": - insertion = f' {{\n .matches = {{DMI_MATCH(DMI_BOARD_NAME, "{board_name}")}},\n .driver_data = (void *)&victus_s_thermal_params,\n }},\n' - else: - insertion = f' "{board_name}",\n' - content = content[:end_idx] + insertion + content[end_idx:] - else: - print(f"Board {board_name} already in {target_array} in orig file? Skipping append.") - else: - print(f"Warning: Could not find array {target_array} in hp-wmi.c") - + segment = content[start_idx:end_idx] + if f'"{board_name}"' not in segment: + if target_array == "victus_s_thermal_profile_boards": + insertion = ( + ' {\n .matches = {DMI_MATCH(DMI_BOARD_NAME, "%s")},\n' + ' .driver_data = (void *)&victus_s_thermal_params,\n },\n' + ) % board_name + else: + insertion = f'\t"{board_name}",\n' + content = content[:end_idx] + insertion + content[end_idx:] with open(target_file, "w") as f: f.write(content) - return True, "Patch applied successfully." def install_driver_temp(self, force=False): - """Installs driver temporarily using insmod. Requires calibration first.""" if self.pwm1_path and self.pwm1_path.exists(): - bypass = self.config.get("bypass_patch_warning", False) - if not force and not bypass: + if not force and not self.config.get("bypass_patch_warning", False): return False, "PWM_DETECTED" - fan_max = self.config.get("fan_max", 0) if fan_max == 0: return False, "Error: Please calibrate first to get Max RPM." - success, msg = self._patch_driver_source(fan_max) if not success: - return False, msg - + return False, msg try: - subprocess.run(["make"], check=True, cwd=OMEN_FAN_DIR, capture_output=True, text=True) + subprocess.run(["make"], check=True, cwd=DRIVER_BUILD_DIR, capture_output=True, text=True) except subprocess.CalledProcessError as e: return False, f"Make failed: {e.stderr}" - - ko_files = list(OMEN_FAN_DIR.glob("*.ko")) + ko_files = list(DRIVER_BUILD_DIR.glob("*.ko")) if not ko_files: return False, "Error: No .ko file found after make." - subprocess.run(["modprobe", "-r", "hp-wmi"], check=False) - try: subprocess.run(["modprobe", "sparse_keymap"], check=True, capture_output=True, text=True) except subprocess.CalledProcessError as e: return False, f"Modprobe sparse_keymap failed: {e.stderr}" - try: subprocess.run(["insmod", str(ko_files[0])], check=True, capture_output=True, text=True) except subprocess.CalledProcessError as e: - subprocess.run(["modprobe", "hp-wmi"], check=False) - return False, f"Insmod failed: {e.stderr}\n(Original driver re-loaded attempts)" - - subprocess.run(["make", "clean"], check=True, cwd=OMEN_FAN_DIR) - + subprocess.run(["modprobe", "hp-wmi"], check=False) + return False, f"Insmod failed: {e.stderr}\n(Original driver re-loaded attempts)" + subprocess.run(["make", "clean"], check=True, cwd=DRIVER_BUILD_DIR) self.config["install_type"] = "temporary" self.save_config() - return True, "Temporary driver installed successfully." def install_driver_perm(self, force=False): - """Installs driver permanently by patching and running install script.""" if self.pwm1_path and self.pwm1_path.exists(): - bypass = self.config.get("bypass_patch_warning", False) - if not force and not bypass: + if not force and not self.config.get("bypass_patch_warning", False): return False, "PWM_DETECTED" - fan_max = self.config.get("fan_max", 0) if fan_max == 0: return False, "Error: Please calibrate first to get Max RPM." - success, msg = self._patch_driver_source(fan_max) if not success: return False, msg - try: subprocess.run(["/bin/bash", "install_driver.sh"], cwd=OMEN_FAN_DIR, check=True, capture_output=True, text=True) except subprocess.CalledProcessError as e: return False, f"Install script failed: {e.stderr}" - self.config["install_type"] = "permanent" self.save_config() - return True, "Permanent driver installed successfully." def check_install_type(self): - """Determines installation type: 'permanent', 'temporary', or None.""" if not (self.pwm1_path and self.pwm1_path.exists()): return None - conf_type = self.config.get("install_type") - if conf_type in ["permanent", "temporary"]: + if conf_type in ("permanent", "temporary"): return conf_type - try: kernel_ver = subprocess.check_output(["uname", "-r"]).decode().strip() hp_driver_dir = Path(f"/lib/modules/{kernel_ver}/kernel/drivers/platform/x86/hp") - - if hp_driver_dir.exists(): - if list(hp_driver_dir.glob("*.bak")): - return "permanent" + if hp_driver_dir.exists() and list(hp_driver_dir.glob("*.bak")): + return "permanent" except Exception: pass - return "temporary" def start_stress_test(self, duration_sec, core_count=None): - """Starts a CPU stress test. Duration handled by caller.""" - import os - import sys - - if core_count is None: - core_count = os.cpu_count() or 4 - + import sys as _sys + core_count = core_count or os.cpu_count() or 4 self.stop_stress_test() - self.stress_processes = [] - cmd = [sys.executable, "-c", "while True: 9999**9999"] - - print(f"Starting stress test on {core_count} cores...") + cmd = [_sys.executable, "-c", "while True: 9999**9999"] try: for _ in range(core_count): - p = subprocess.Popen(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) - self.stress_processes.append(p) + self.stress_processes.append(subprocess.Popen(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)) return True except Exception as e: print(f"Error starting stress test: {e}") @@ -536,86 +397,66 @@ def start_stress_test(self, duration_sec, core_count=None): return False def stop_stress_test(self): - """Stops the running stress test.""" - if hasattr(self, 'stress_processes') and self.stress_processes: - for p in self.stress_processes: - try: - p.terminate() - except Exception: - pass - - for p in self.stress_processes: - try: - p.wait(timeout=0.1) - except subprocess.TimeoutExpired: - p.kill() - - self.stress_processes = [] - print("Stopped stress test.") - + if not getattr(self, "stress_processes", None): + return + for p in self.stress_processes: + try: + p.terminate() + except Exception: + pass + for p in self.stress_processes: + try: + p.wait(timeout=0.1) + except subprocess.TimeoutExpired: + p.kill() + self.stress_processes = [] + print("Stopped stress test.") + def set_bios_control(self, enabled): - """Enables or disables BIOS fan control by writing to EC registers.""" try: - subprocess.run(["modprobe", "ec_sys", "write_support=1"], check=True) + subprocess.run(["modprobe", "ec_sys", "write_support=1"], check=True) except Exception as e: print(f"Failed to load ec_sys: {e}") return False - ECIO_FILE = "/sys/kernel/debug/ec/ec0/io" - BIOS_OFFSET = 98 - TIMER_OFFSET = 99 - FAN1_OFFSET = 52 - FAN2_OFFSET = 53 - try: with open(ECIO_FILE, "r+b") as ec: if not enabled: - ec.seek(BIOS_OFFSET) + ec.seek(98) ec.write(bytes([6])) time.sleep(0.1) - ec.seek(TIMER_OFFSET) + ec.seek(99) ec.write(bytes([0])) else: - ec.seek(BIOS_OFFSET) + ec.seek(98) ec.write(bytes([0])) - ec.seek(FAN1_OFFSET) + ec.seek(52) ec.write(bytes([0])) - ec.seek(FAN2_OFFSET) + ec.seek(53) ec.write(bytes([0])) return True except Exception as e: print(f"Error setting BIOS control: {e}") return False - # Service Management def create_service(self): - """ - Creates and enables a systemd service to run 'omen_cli.py serve'. - """ - import sys - service_content = f"""[Unit] -Description=HP Omen Fan Control Service -After=multi-user.target - -[Service] -Type=simple -ExecStart={sys.executable} {str(OMEN_FAN_DIR / 'omen_cli.py')} serve -WorkingDirectory={str(OMEN_FAN_DIR)} -Restart=on-failure -StartLimitBurst=5 -RestartSec=5 -User=root - -[Install] -WantedBy=multi-user.target -""" - service_path = Path("/etc/systemd/system/omen-fan-control.service") - + """Creates and enables systemd service using packaged unit template (placeholder @EXECSTART@).""" + unit_lib = Path("/usr/lib/systemd/system/omen-fan-control.service") + unit_etc = Path("/etc/systemd/system/omen-fan-control.service") try: - with open("omen-fan-control.service", "w") as f: + if unit_lib.exists(): + # Package-installed unit: just enable and start, do not overwrite + subprocess.run(["systemctl", "daemon-reload"], check=True) + subprocess.run(["systemctl", "enable", "omen-fan-control.service"], check=True) + subprocess.run(["systemctl", "start", "omen-fan-control.service"], check=True) + return True, "Service enabled and started." + template_path = Path(__file__).parent / "data" / "omen-fan-control.service" + if not template_path.exists(): + return False, f"Service template not found: {template_path}" + exec_start = f"{sys.executable} -m omen_fan_control.cli serve" + service_content = template_path.read_text().replace("@EXECSTART@", exec_start) + with open(unit_etc, "w") as f: f.write(service_content) - - subprocess.run(["mv", "omen-fan-control.service", str(service_path)], check=True) subprocess.run(["systemctl", "daemon-reload"], check=True) subprocess.run(["systemctl", "enable", "omen-fan-control.service"], check=True) subprocess.run(["systemctl", "start", "omen-fan-control.service"], check=True) @@ -624,22 +465,19 @@ def create_service(self): return False, f"Failed to create service: {e}" def remove_service(self): - """Stops and removes the systemd service.""" try: subprocess.run(["systemctl", "stop", "omen-fan-control.service"], check=False) subprocess.run(["systemctl", "disable", "omen-fan-control.service"], check=False) - - service_path = Path("/etc/systemd/system/omen-fan-control.service") - if service_path.exists(): - subprocess.run(["rm", str(service_path)], check=True) - + unit_etc = Path("/etc/systemd/system/omen-fan-control.service") + if unit_etc.exists(): + unit_etc.unlink() subprocess.run(["systemctl", "daemon-reload"], check=True) return True, "Service removed." except Exception as e: return False, f"Failed to remove service: {e}" def restart_service(self): - """Restarts the systemd service.""" + """Restart the systemd service.""" try: subprocess.run(["systemctl", "restart", "omen-fan-control.service"], check=True) return True, "Service restarted." @@ -647,96 +485,62 @@ def restart_service(self): return False, f"Failed to restart service: {e}" def is_service_installed(self): - """Checks if service file exists.""" - return Path("/etc/systemd/system/omen-fan-control.service").exists() + return ( + Path("/etc/systemd/system/omen-fan-control.service").exists() + or Path("/usr/lib/systemd/system/omen-fan-control.service").exists() + ) def is_service_running(self): - """Checks if service is actively running.""" try: - # Check active state res = subprocess.run(["systemctl", "is-active", "omen-fan-control.service"], capture_output=True, text=True) return res.stdout.strip() == "active" except Exception: return False def restore_driver(self): - """Restores the original driver from backup files and removes DKMS/hooks.""" messages = [] - + dkms_name, dkms_version = "hp-wmi-omen", "1.0" try: - # 1. Remove DKMS module if installed - dkms_name = "hp-wmi-omen" - dkms_version = "1.0" try: result = subprocess.run(["dkms", "status"], capture_output=True, text=True) if dkms_name in result.stdout: subprocess.run(["dkms", "remove", f"{dkms_name}/{dkms_version}", "--all"], check=False) messages.append("Removed DKMS module.") except FileNotFoundError: - pass # DKMS not installed - - # 2. Remove DKMS source directory - dkms_src = Path(f"/usr/src/{dkms_name}-{dkms_version}") - if dkms_src.exists() and dkms_name in str(dkms_src) and len(str(dkms_src)) > 10: - subprocess.run(["rm", "-rf", str(dkms_src)], check=False) - - # 3. Remove our kernel hooks source - hook_src = Path(f"/usr/src/{dkms_name}") - if hook_src.exists() and dkms_name in str(hook_src) and len(str(hook_src)) > 10: - subprocess.run(["rm", "-rf", str(hook_src)], check=False) - - # 4. Remove distro-specific kernel hooks - hook_paths = [ - "/etc/pacman.d/hooks/90-hp-wmi-omen.hook", # Arch - "/etc/kernel/postinst.d/zz-hp-wmi-omen", # Debian/Ubuntu - "/etc/kernel/install.d/99-hp-wmi-omen.install", # Fedora - ] - for hook in hook_paths: + pass + for d in [Path(f"/usr/src/{dkms_name}-{dkms_version}"), Path(f"/usr/src/{dkms_name}")]: + if d.exists() and dkms_name in str(d): + subprocess.run(["rm", "-rf", str(d)], check=False) + for hook in ["/etc/pacman.d/hooks/90-hp-wmi-omen.hook", "/etc/kernel/postinst.d/zz-hp-wmi-omen", "/etc/kernel/install.d/99-hp-wmi-omen.install"]: if Path(hook).exists(): - subprocess.run(["rm", hook], check=False) + Path(hook).unlink() messages.append(f"Removed hook: {Path(hook).name}") - - # 5. Restore backup files kernel_ver = subprocess.check_output(["uname", "-r"]).decode().strip() - search_paths = [ - Path(f"/lib/modules/{kernel_ver}/kernel/drivers/platform/x86/hp"), - Path(f"/lib/modules/{kernel_ver}/updates") - ] - restored_count = 0 - - for search_dir in search_paths: + for search_dir in [Path(f"/lib/modules/{kernel_ver}/kernel/drivers/platform/x86/hp"), Path(f"/lib/modules/{kernel_ver}/updates")]: if search_dir.exists(): - for bak_file in search_dir.rglob("*.bak"): # Recursive search for updates dir + for bak_file in search_dir.rglob("*.bak"): target = bak_file.parent / bak_file.stem subprocess.run(["mv", str(bak_file), str(target)], check=True) restored_count += 1 - if restored_count == 0 and not messages: if self.config.get("install_type") == "temporary": - subprocess.run(["modprobe", "-r", "hp-wmi"], check=False) - subprocess.run(["modprobe", "hp-wmi"], check=False) - self.config.pop("install_type", None) - self.save_config() - return True, "Temporary driver unloaded. (No backups needed)" - + subprocess.run(["modprobe", "-r", "hp-wmi"], check=False) + subprocess.run(["modprobe", "hp-wmi"], check=False) + self.config.pop("install_type", None) + self.save_config() + return True, "Temporary driver unloaded. (No backups needed)" return False, "No backup files (.bak) found to restore." - subprocess.run(["depmod", "-a"], check=True) - subprocess.run(["modprobe", "-r", "hp-wmi"], check=False) + subprocess.run(["modprobe", "-r", "hp-wmi"], check=False) subprocess.run(["modprobe", "hp-wmi"], check=True) - self.config.pop("install_type", None) self.save_config() - if restored_count > 0: messages.append(f"Restored {restored_count} driver backup(s).") messages.append("Driver reloaded.") - return True, " ".join(messages) - except subprocess.CalledProcessError as e: return False, f"Error restoring driver: {e}" except Exception as e: - return False, f"Error: {e}" - + return False, f"Error: {e}" \ No newline at end of file diff --git a/uv.lock b/uv.lock new file mode 100644 index 0000000..b36f33c --- /dev/null +++ b/uv.lock @@ -0,0 +1,256 @@ +version = 1 +revision = 3 +requires-python = ">=3.10" + +[[package]] +name = "build" +version = "1.4.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "colorama", marker = "os_name == 'nt'" }, + { name = "importlib-metadata", marker = "python_full_version < '3.10.2'" }, + { name = "packaging" }, + { name = "pyproject-hooks" }, + { name = "tomli", marker = "python_full_version < '3.11'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/42/18/94eaffda7b329535d91f00fe605ab1f1e5cd68b2074d03f255c7d250687d/build-1.4.0.tar.gz", hash = "sha256:f1b91b925aa322be454f8330c6fb48b465da993d1e7e7e6fa35027ec49f3c936", size = 50054, upload-time = "2026-01-08T16:41:47.696Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/c5/0d/84a4380f930db0010168e0aa7b7a8fed9ba1835a8fbb1472bc6d0201d529/build-1.4.0-py3-none-any.whl", hash = "sha256:6a07c1b8eb6f2b311b96fcbdbce5dab5fe637ffda0fd83c9cac622e927501596", size = 24141, upload-time = "2026-01-08T16:41:46.453Z" }, +] + +[[package]] +name = "click" +version = "8.3.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "colorama", marker = "sys_platform == 'win32'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/3d/fa/656b739db8587d7b5dfa22e22ed02566950fbfbcdc20311993483657a5c0/click-8.3.1.tar.gz", hash = "sha256:12ff4785d337a1bb490bb7e9c2b1ee5da3112e94a8622f26a6c77f5d2fc6842a", size = 295065, upload-time = "2025-11-15T20:45:42.706Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/98/78/01c019cdb5d6498122777c1a43056ebb3ebfeef2076d9d026bfe15583b2b/click-8.3.1-py3-none-any.whl", hash = "sha256:981153a64e25f12d547d3426c367a4857371575ee7ad18df2a6183ab0545b2a6", size = 108274, upload-time = "2025-11-15T20:45:41.139Z" }, +] + +[[package]] +name = "colorama" +version = "0.4.6" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44", size = 27697, upload-time = "2022-10-25T02:36:22.414Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335, upload-time = "2022-10-25T02:36:20.889Z" }, +] + +[[package]] +name = "importlib-metadata" +version = "8.7.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "zipp" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/f3/49/3b30cad09e7771a4982d9975a8cbf64f00d4a1ececb53297f1d9a7be1b10/importlib_metadata-8.7.1.tar.gz", hash = "sha256:49fef1ae6440c182052f407c8d34a68f72efc36db9ca90dc0113398f2fdde8bb", size = 57107, upload-time = "2025-12-21T10:00:19.278Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/fa/5e/f8e9a1d23b9c20a551a8a02ea3637b4642e22c2626e3a13a9a29cdea99eb/importlib_metadata-8.7.1-py3-none-any.whl", hash = "sha256:5a1f80bf1daa489495071efbb095d75a634cf28a8bc299581244063b53176151", size = 27865, upload-time = "2025-12-21T10:00:18.329Z" }, +] + +[[package]] +name = "omen-fan-control" +version = "1.0.0" +source = { editable = "." } +dependencies = [ + { name = "click" }, + { name = "pyqt6" }, +] + +[package.optional-dependencies] +dev = [ + { name = "build" }, + { name = "ruff" }, +] + +[package.dev-dependencies] +dev = [ + { name = "build" }, + { name = "ruff" }, +] + +[package.metadata] +requires-dist = [ + { name = "build", marker = "extra == 'dev'", specifier = ">=1.0" }, + { name = "click", specifier = ">=8.0" }, + { name = "pyqt6", specifier = ">=6.4" }, + { name = "ruff", marker = "extra == 'dev'", specifier = ">=0.1" }, +] +provides-extras = ["dev"] + +[package.metadata.requires-dev] +dev = [ + { name = "build", specifier = ">=1.0" }, + { name = "ruff", specifier = ">=0.1" }, +] + +[[package]] +name = "packaging" +version = "26.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/65/ee/299d360cdc32edc7d2cf530f3accf79c4fca01e96ffc950d8a52213bd8e4/packaging-26.0.tar.gz", hash = "sha256:00243ae351a257117b6a241061796684b084ed1c516a08c48a3f7e147a9d80b4", size = 143416, upload-time = "2026-01-21T20:50:39.064Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b7/b9/c538f279a4e237a006a2c98387d081e9eb060d203d8ed34467cc0f0b9b53/packaging-26.0-py3-none-any.whl", hash = "sha256:b36f1fef9334a5588b4166f8bcd26a14e521f2b55e6b9de3aaa80d3ff7a37529", size = 74366, upload-time = "2026-01-21T20:50:37.788Z" }, +] + +[[package]] +name = "pyproject-hooks" +version = "1.2.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/e7/82/28175b2414effca1cdac8dc99f76d660e7a4fb0ceefa4b4ab8f5f6742925/pyproject_hooks-1.2.0.tar.gz", hash = "sha256:1e859bd5c40fae9448642dd871adf459e5e2084186e8d2c2a79a824c970da1f8", size = 19228, upload-time = "2024-09-29T09:24:13.293Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/bd/24/12818598c362d7f300f18e74db45963dbcb85150324092410c8b49405e42/pyproject_hooks-1.2.0-py3-none-any.whl", hash = "sha256:9e5c6bfa8dcc30091c74b0cf803c81fdd29d94f01992a7707bc97babb1141913", size = 10216, upload-time = "2024-09-29T09:24:11.978Z" }, +] + +[[package]] +name = "pyqt6" +version = "6.10.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "pyqt6-qt6" }, + { name = "pyqt6-sip" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/96/03/e756f52e8b0d7bb5527baf8c46d59af0746391943bdb8655acba22ee4168/pyqt6-6.10.2.tar.gz", hash = "sha256:6c0db5d8cbb9a3e7e2b5b51d0ff3f283121fa27b864db6d2f35b663c9be5cc83", size = 1085573, upload-time = "2026-01-08T16:40:00.244Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/fb/3f/f073a980969aa485ef288eb2e3b94c223ba9c7ac9941543f19b51659b98d/pyqt6-6.10.2-cp39-abi3-macosx_10_14_universal2.whl", hash = "sha256:37ae7c1183fe4dd0c6aefd2006a35731245de1cb6f817bb9e414a3e4848dfd6d", size = 60244482, upload-time = "2026-01-08T16:38:50.837Z" }, + { url = "https://files.pythonhosted.org/packages/ec/3e/9a015651ec71cea2e2f960c37edeb21623ba96a74956c0827def837f7c6b/pyqt6-6.10.2-cp39-abi3-manylinux_2_34_x86_64.whl", hash = "sha256:78e1b3d5763e4cbc84485aef600e0aba5e1932fd263b716f92cd1a40dfa5e924", size = 37899440, upload-time = "2026-01-08T16:39:09.027Z" }, + { url = "https://files.pythonhosted.org/packages/51/74/a88fec2b99700270ca5d7dc7d650236a4990ed6fc88e055ca0fc8a339ee3/pyqt6-6.10.2-cp39-abi3-manylinux_2_39_aarch64.whl", hash = "sha256:bbc3af541bbecd27301bfe69fe445aa1611a9b490bd3de77306b12df632f7ec6", size = 40748467, upload-time = "2026-01-08T16:39:29.551Z" }, + { url = "https://files.pythonhosted.org/packages/75/34/be7a55529607b21db00a49ca53cb07c3092d2a5a95ea19bb95cfa0346904/pyqt6-6.10.2-cp39-abi3-win_amd64.whl", hash = "sha256:bd328cb70bc382c48861cd5f0a11b2b8ae6f5692d5a2d6679ba52785dced327b", size = 26015391, upload-time = "2026-01-08T16:39:42.946Z" }, + { url = "https://files.pythonhosted.org/packages/af/de/d9c88f976602b7884fec4ad54a4575d48e23e4f390e5357ea83917358846/pyqt6-6.10.2-cp39-abi3-win_arm64.whl", hash = "sha256:7901ba1df024b7ee9fdacfb2b7661aeb3749ae8b0bef65428077de3e0450eabb", size = 26208415, upload-time = "2026-01-08T16:39:57.751Z" }, +] + +[[package]] +name = "pyqt6-qt6" +version = "6.10.2" +source = { registry = "https://pypi.org/simple" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/9a/eb/f04d547d8ed9f20c7b246db4ef5d93b49cab4692009a10652ed0a8b9d2aa/pyqt6_qt6-6.10.2-py3-none-macosx_10_14_x86_64.whl", hash = "sha256:5761cfccc721da2311c3f1213577f0ff1df07bbbbe3fa3a209a256b82cf057e3", size = 68688870, upload-time = "2026-01-29T12:26:48.619Z" }, + { url = "https://files.pythonhosted.org/packages/ce/c8/d99e65ab01c2402fb6bc4f77abef7244f7d5fb2f2e6d5b0abdf71bb2e4fc/pyqt6_qt6-6.10.2-py3-none-macosx_11_0_arm64.whl", hash = "sha256:6dda853a8db1b8d1a2ddbbe76cc6c3aa86614cad14056bd3c0435d8feea73b2d", size = 62512013, upload-time = "2026-01-29T12:27:24.642Z" }, + { url = "https://files.pythonhosted.org/packages/d5/fe/01fd9b9d2ca139ef61582f2e2da249fa169229144294c1bb27db59ad8420/pyqt6_qt6-6.10.2-py3-none-manylinux_2_34_x86_64.whl", hash = "sha256:19c10b5f0806e9f9bac2c9759bd5d7d19a78967f330fd60a2db409177fa76e49", size = 84028760, upload-time = "2026-01-29T12:28:03.267Z" }, + { url = "https://files.pythonhosted.org/packages/f4/20/a0d027ebb267d3afaf319d94efe1ff4d667004ee83b96701329a4d11fb95/pyqt6_qt6-6.10.2-py3-none-manylinux_2_39_aarch64.whl", hash = "sha256:2e60d616861ca4565cd295418d605975aa2dc407ba4b94c1586a70c92e9cb052", size = 83063975, upload-time = "2026-01-29T12:28:48.928Z" }, + { url = "https://files.pythonhosted.org/packages/06/8e/595f215876d507417cc8565e05519916d3b0b76baedea6a1e4e5105633fc/pyqt6_qt6-6.10.2-py3-none-win_amd64.whl", hash = "sha256:c4b7f7d66cc58bddf1bc1ca28dfcf7a45f58cfcb11d81d13a0510409dd4957ac", size = 78433821, upload-time = "2026-01-29T12:29:35.493Z" }, + { url = "https://files.pythonhosted.org/packages/50/5f/2196e2b536217b87cb3d2ce13ef8f7607d08b02f1990a4bd84a88d293a3c/pyqt6_qt6-6.10.2-py3-none-win_arm64.whl", hash = "sha256:7164a6f0c1335358a3026df9865c8f75395b01f60f0dcd2f66c029ec16fc83d2", size = 58354426, upload-time = "2026-01-29T12:30:02.95Z" }, +] + +[[package]] +name = "pyqt6-sip" +version = "13.11.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/e3/7d/d2916048e2e3960f68cb4e93907639844f7b8ff95897dcc98553776ccdfc/pyqt6_sip-13.11.0.tar.gz", hash = "sha256:d463af37738bda1856c9ef513e5620a37b7a005e9d589c986c3304db4a8a14d3", size = 92509, upload-time = "2026-01-13T16:01:32.16Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/1c/43/5f0165d15e40a1dd0b954bb64c5832255b28008ffdad6d0084e01f3cda9d/pyqt6_sip-13.11.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:90b597feae3c374eb1af7bfc515836aa39829ff3a1dffa5fe92ba139d273946a", size = 110755, upload-time = "2026-01-13T16:00:56.424Z" }, + { url = "https://files.pythonhosted.org/packages/87/ff/4df67b44e2b45e6f1c235b46eb6276afff2dd5b0bdb0fee8b240b61d0b9c/pyqt6_sip-13.11.0-cp310-cp310-manylinux1_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:261f8f7063c862863f05629219be08be9bddd01d1a83181f8439d19852ae1571", size = 282224, upload-time = "2026-01-13T16:00:59.714Z" }, + { url = "https://files.pythonhosted.org/packages/72/b9/036467387f7b025c0a3a7d3fb7f4a014cc7d69c08f3221cb758ffc98de0e/pyqt6_sip-13.11.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b8532a5612762a5c1859e4b38359f847e07596ec210942221e22b10df5327fcc", size = 306070, upload-time = "2026-01-13T16:00:58.007Z" }, + { url = "https://files.pythonhosted.org/packages/de/dc/7aa44c77790f53f74de94da5c02acd6c919f17a44cc92096f7e6ab3a3724/pyqt6_sip-13.11.0-cp310-cp310-win_amd64.whl", hash = "sha256:87edd15791c7d20fa3ffc68e6f4825f989a6510c11019eb5a11c1622b8802f8d", size = 54107, upload-time = "2026-01-13T16:01:01.334Z" }, + { url = "https://files.pythonhosted.org/packages/4a/41/1c2097aad646f7ef6be9cfd2fd4814ad6bbdba7d53a622ad56e00f88dc72/pyqt6_sip-13.11.0-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:6e329ccc3a6502e2b774ef62ab843ac8b3f32191324e8230e6dde78c1c0df5a8", size = 110804, upload-time = "2026-01-13T16:01:02.527Z" }, + { url = "https://files.pythonhosted.org/packages/e0/d3/51143a254a7c9e9650c3eedfc35b967cdcd180a289c6fa2a937c57fe405a/pyqt6_sip-13.11.0-cp311-cp311-manylinux1_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:364424dacdee9e0a2a723646b5608139629ad9bde318dd755d86f5e0ba123c79", size = 291442, upload-time = "2026-01-13T16:01:05.424Z" }, + { url = "https://files.pythonhosted.org/packages/0c/5c/d62e0ded4fdd5abf6a3085a65aa229c863b334758555af1f7b79af9bc003/pyqt6_sip-13.11.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:132ee69d935c14bb4ced2a811ef333200c7aa50324bd7caadefd7d5874495225", size = 317793, upload-time = "2026-01-13T16:01:04.183Z" }, + { url = "https://files.pythonhosted.org/packages/c0/d4/34f3fb522323a5336e31a51ab7ae3103ebc0c8e741bff9630f29480cdca2/pyqt6_sip-13.11.0-cp311-cp311-win_amd64.whl", hash = "sha256:341e52e702d41872515794dea6265ee56b8625c9d3c74ea0468124f0bd675f8b", size = 54101, upload-time = "2026-01-13T16:01:06.504Z" }, + { url = "https://files.pythonhosted.org/packages/a9/a1/37109ec33ead4b9cc62294b48a1ba2b4899cb0d009eb1763d61e3a89ab21/pyqt6_sip-13.11.0-cp311-cp311-win_arm64.whl", hash = "sha256:489fdd0910f8c1d5d40255b4cd7b45f4a4549f9a599512bc6b2cc8d384e28852", size = 48359, upload-time = "2026-01-13T16:01:07.732Z" }, + { url = "https://files.pythonhosted.org/packages/53/a6/0e4d8fa7d6deb750bd0fdf89024e39c71fb127efb5eeedfab6830ad6679a/pyqt6_sip-13.11.0-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:6b3267cd93b7f4da6fdf9a6a26f3baed8faae06e5cdd76235f2acc2116c40a54", size = 112367, upload-time = "2026-01-13T16:01:09.08Z" }, + { url = "https://files.pythonhosted.org/packages/66/e6/25dc20a03c46000e8b93aaf79347227926b67959283e5aab797daa7f64d8/pyqt6_sip-13.11.0-cp312-cp312-manylinux1_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:c30248d9bbe54c46a78e5d549da50295ecd6584b965597f751e272f000fb8527", size = 301150, upload-time = "2026-01-13T16:01:12.385Z" }, + { url = "https://files.pythonhosted.org/packages/11/9f/e850cd350aade789660cafba38c00777e686040c06b8cd0b45339b80fcba/pyqt6_sip-13.11.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9c367b53a91e575ef66c1375f899713bdaf0a8b2c64b95ac226e9644854a4984", size = 323303, upload-time = "2026-01-13T16:01:10.736Z" }, + { url = "https://files.pythonhosted.org/packages/77/26/5261d62108f7579407230f8c1d4dda43c18b5600ce70bf3becb2f997d5cc/pyqt6_sip-13.11.0-cp312-cp312-win_amd64.whl", hash = "sha256:077958105c2ea2f62be2f1a7611ff8bd44cb52fb5ea8fc8c59ea949144acb7b5", size = 53461, upload-time = "2026-01-13T16:01:13.875Z" }, + { url = "https://files.pythonhosted.org/packages/46/80/6c88b97eda309d6babb7292200bf51165dc06d0204d891b7bf1fb17a8ed0/pyqt6_sip-13.11.0-cp312-cp312-win_arm64.whl", hash = "sha256:52812471619d3d3750b940d7d124cd0954107656924921ac177e098ba36362fb", size = 48650, upload-time = "2026-01-13T16:01:14.897Z" }, + { url = "https://files.pythonhosted.org/packages/df/a0/46abcae4fce175a326185460a02c13ab81332bca7dd55c1e853ba6aee71e/pyqt6_sip-13.11.0-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:929716eebde1a64ffdb6b1715db6a22aefd5634d6df84858c7deb5e85be84fdf", size = 112353, upload-time = "2026-01-13T16:01:16.152Z" }, + { url = "https://files.pythonhosted.org/packages/0e/38/27c3aa3f153fcd83a0765fedf8e44a1136f189a322bcc9c494c5b3793cd7/pyqt6_sip-13.11.0-cp313-cp313-manylinux1_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:a75144e8a0bcf9d1a9069011890401748af353749f1de1b6a314b880781edf9d", size = 301497, upload-time = "2026-01-13T16:01:20.531Z" }, + { url = "https://files.pythonhosted.org/packages/6f/ac/1053ffce45e4174f0a8174557b88537aa82bf96ba03c7dd208c59de36f69/pyqt6_sip-13.11.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8082b5f57ffad5dddf5efcf0ef5eaf94841395aa4e7c374c79ef24cf49b0f0ce", size = 323498, upload-time = "2026-01-13T16:01:17.859Z" }, + { url = "https://files.pythonhosted.org/packages/40/d3/447b30d1f00cc50ad9e5c53b2e920068606b16857da83f8036b390c79fad/pyqt6_sip-13.11.0-cp313-cp313-win_amd64.whl", hash = "sha256:8d49b5bf3d8d36cd7db93ddc54cd09dbba96a3fd926e445ef75499b41e47b5a3", size = 53469, upload-time = "2026-01-13T16:01:21.762Z" }, + { url = "https://files.pythonhosted.org/packages/92/67/77e6fafcabd01c0a11166ab7464509896f137929f82c4f2e03aea1bf41b3/pyqt6_sip-13.11.0-cp313-cp313-win_arm64.whl", hash = "sha256:293eac1b53c66c54b03266cc30015ec77454af679043a4f188b9bb80a9656996", size = 48643, upload-time = "2026-01-13T16:01:22.669Z" }, + { url = "https://files.pythonhosted.org/packages/ff/28/a5178c8e005bafbf9c0fd507f45a3eef619ab582811414a0a461ee75994f/pyqt6_sip-13.11.0-cp314-cp314-macosx_10_15_universal2.whl", hash = "sha256:4dc9c4df24af0571423c3e85b5c008bad42ed48558eef80fbc3e5d30274c5abb", size = 112431, upload-time = "2026-01-13T16:01:23.832Z" }, + { url = "https://files.pythonhosted.org/packages/13/3c/02770b02b5a05779e26bd02c202c2fd32aa38e225d01f14c06908e33738c/pyqt6_sip-13.11.0-cp314-cp314-manylinux1_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:c974d5a193f32e55e746e9b63138503163ac63500dbb1fd67233d8a8d71369bd", size = 301236, upload-time = "2026-01-13T16:01:28.733Z" }, + { url = "https://files.pythonhosted.org/packages/40/47/5af493a698cc520581ca1000b4ab09b8182992053ffe2478062dde5e4671/pyqt6_sip-13.11.0-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4284540ffccd8349763ddce3518264dde62f20556720d4061b9c895e09011ca0", size = 323919, upload-time = "2026-01-13T16:01:25.122Z" }, + { url = "https://files.pythonhosted.org/packages/b7/2d/64b26e21183a7ff180105871dd5983a8da539d8768921728268dc6d0a73d/pyqt6_sip-13.11.0-cp314-cp314-win_amd64.whl", hash = "sha256:9bd81cb351640abc803ea2fe7262b5adea28615c9b96fd103d1b6f3459937211", size = 55078, upload-time = "2026-01-13T16:01:29.853Z" }, + { url = "https://files.pythonhosted.org/packages/7e/36/23f699fa8b1c3fcc312ecd12661a1df6057d92e16d4def2399b59cf7bf22/pyqt6_sip-13.11.0-cp314-cp314-win_arm64.whl", hash = "sha256:cd95ec98f8edb15bcea832b8657809f69d758bc4151cc6fd7790c0181949e45f", size = 49465, upload-time = "2026-01-13T16:01:31.174Z" }, +] + +[[package]] +name = "ruff" +version = "0.15.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/06/04/eab13a954e763b0606f460443fcbf6bb5a0faf06890ea3754ff16523dce5/ruff-0.15.2.tar.gz", hash = "sha256:14b965afee0969e68bb871eba625343b8673375f457af4abe98553e8bbb98342", size = 4558148, upload-time = "2026-02-19T22:32:20.271Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/2f/70/3a4dc6d09b13cb3e695f28307e5d889b2e1a66b7af9c5e257e796695b0e6/ruff-0.15.2-py3-none-linux_armv6l.whl", hash = "sha256:120691a6fdae2f16d65435648160f5b81a9625288f75544dc40637436b5d3c0d", size = 10430565, upload-time = "2026-02-19T22:32:41.824Z" }, + { url = "https://files.pythonhosted.org/packages/71/0b/bb8457b56185ece1305c666dc895832946d24055be90692381c31d57466d/ruff-0.15.2-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:a89056d831256099658b6bba4037ac6dd06f49d194199215befe2bb10457ea5e", size = 10820354, upload-time = "2026-02-19T22:32:07.366Z" }, + { url = "https://files.pythonhosted.org/packages/2d/c1/e0532d7f9c9e0b14c46f61b14afd563298b8b83f337b6789ddd987e46121/ruff-0.15.2-py3-none-macosx_11_0_arm64.whl", hash = "sha256:e36dee3a64be0ebd23c86ffa3aa3fd3ac9a712ff295e192243f814a830b6bd87", size = 10170767, upload-time = "2026-02-19T22:32:13.188Z" }, + { url = "https://files.pythonhosted.org/packages/47/e8/da1aa341d3af017a21c7a62fb5ec31d4e7ad0a93ab80e3a508316efbcb23/ruff-0.15.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a9fb47b6d9764677f8c0a193c0943ce9a05d6763523f132325af8a858eadc2b9", size = 10529591, upload-time = "2026-02-19T22:32:02.547Z" }, + { url = "https://files.pythonhosted.org/packages/93/74/184fbf38e9f3510231fbc5e437e808f0b48c42d1df9434b208821efcd8d6/ruff-0.15.2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:f376990f9d0d6442ea9014b19621d8f2aaf2b8e39fdbfc79220b7f0c596c9b80", size = 10260771, upload-time = "2026-02-19T22:32:36.938Z" }, + { url = "https://files.pythonhosted.org/packages/05/ac/605c20b8e059a0bc4b42360414baa4892ff278cec1c91fff4be0dceedefd/ruff-0.15.2-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2dcc987551952d73cbf5c88d9fdee815618d497e4df86cd4c4824cc59d5dd75f", size = 11045791, upload-time = "2026-02-19T22:32:31.642Z" }, + { url = "https://files.pythonhosted.org/packages/fd/52/db6e419908f45a894924d410ac77d64bdd98ff86901d833364251bd08e22/ruff-0.15.2-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:42a47fd785cbe8c01b9ff45031af875d101b040ad8f4de7bbb716487c74c9a77", size = 11879271, upload-time = "2026-02-19T22:32:29.305Z" }, + { url = "https://files.pythonhosted.org/packages/3e/d8/7992b18f2008bdc9231d0f10b16df7dda964dbf639e2b8b4c1b4e91b83af/ruff-0.15.2-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:cbe9f49354866e575b4c6943856989f966421870e85cd2ac94dccb0a9dcb2fea", size = 11303707, upload-time = "2026-02-19T22:32:22.492Z" }, + { url = "https://files.pythonhosted.org/packages/d7/02/849b46184bcfdd4b64cde61752cc9a146c54759ed036edd11857e9b8443b/ruff-0.15.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b7a672c82b5f9887576087d97be5ce439f04bbaf548ee987b92d3a7dede41d3a", size = 11149151, upload-time = "2026-02-19T22:32:44.234Z" }, + { url = "https://files.pythonhosted.org/packages/70/04/f5284e388bab60d1d3b99614a5a9aeb03e0f333847e2429bebd2aaa1feec/ruff-0.15.2-py3-none-manylinux_2_31_riscv64.whl", hash = "sha256:72ecc64f46f7019e2bcc3cdc05d4a7da958b629a5ab7033195e11a438403d956", size = 11091132, upload-time = "2026-02-19T22:32:24.691Z" }, + { url = "https://files.pythonhosted.org/packages/fa/ae/88d844a21110e14d92cf73d57363fab59b727ebeabe78009b9ccb23500af/ruff-0.15.2-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:8dcf243b15b561c655c1ef2f2b0050e5d50db37fe90115507f6ff37d865dc8b4", size = 10504717, upload-time = "2026-02-19T22:32:26.75Z" }, + { url = "https://files.pythonhosted.org/packages/64/27/867076a6ada7f2b9c8292884ab44d08fd2ba71bd2b5364d4136f3cd537e1/ruff-0.15.2-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:dab6941c862c05739774677c6273166d2510d254dac0695c0e3f5efa1b5585de", size = 10263122, upload-time = "2026-02-19T22:32:10.036Z" }, + { url = "https://files.pythonhosted.org/packages/e7/ef/faf9321d550f8ebf0c6373696e70d1758e20ccdc3951ad7af00c0956be7c/ruff-0.15.2-py3-none-musllinux_1_2_i686.whl", hash = "sha256:1b9164f57fc36058e9a6806eb92af185b0697c9fe4c7c52caa431c6554521e5c", size = 10735295, upload-time = "2026-02-19T22:32:39.227Z" }, + { url = "https://files.pythonhosted.org/packages/2f/55/e8089fec62e050ba84d71b70e7834b97709ca9b7aba10c1a0b196e493f97/ruff-0.15.2-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:80d24fcae24d42659db7e335b9e1531697a7102c19185b8dc4a028b952865fd8", size = 11241641, upload-time = "2026-02-19T22:32:34.617Z" }, + { url = "https://files.pythonhosted.org/packages/23/01/1c30526460f4d23222d0fabd5888868262fd0e2b71a00570ca26483cd993/ruff-0.15.2-py3-none-win32.whl", hash = "sha256:fd5ff9e5f519a7e1bd99cbe8daa324010a74f5e2ebc97c6242c08f26f3714f6f", size = 10507885, upload-time = "2026-02-19T22:32:15.635Z" }, + { url = "https://files.pythonhosted.org/packages/5c/10/3d18e3bbdf8fc50bbb4ac3cc45970aa5a9753c5cb51bf9ed9a3cd8b79fa3/ruff-0.15.2-py3-none-win_amd64.whl", hash = "sha256:d20014e3dfa400f3ff84830dfb5755ece2de45ab62ecea4af6b7262d0fb4f7c5", size = 11623725, upload-time = "2026-02-19T22:32:04.947Z" }, + { url = "https://files.pythonhosted.org/packages/6d/78/097c0798b1dab9f8affe73da9642bb4500e098cb27fd8dc9724816ac747b/ruff-0.15.2-py3-none-win_arm64.whl", hash = "sha256:cabddc5822acdc8f7b5527b36ceac55cc51eec7b1946e60181de8fe83ca8876e", size = 10941649, upload-time = "2026-02-19T22:32:18.108Z" }, +] + +[[package]] +name = "tomli" +version = "2.4.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/82/30/31573e9457673ab10aa432461bee537ce6cef177667deca369efb79df071/tomli-2.4.0.tar.gz", hash = "sha256:aa89c3f6c277dd275d8e243ad24f3b5e701491a860d5121f2cdd399fbb31fc9c", size = 17477, upload-time = "2026-01-11T11:22:38.165Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/3c/d9/3dc2289e1f3b32eb19b9785b6a006b28ee99acb37d1d47f78d4c10e28bf8/tomli-2.4.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:b5ef256a3fd497d4973c11bf142e9ed78b150d36f5773f1ca6088c230ffc5867", size = 153663, upload-time = "2026-01-11T11:21:45.27Z" }, + { url = "https://files.pythonhosted.org/packages/51/32/ef9f6845e6b9ca392cd3f64f9ec185cc6f09f0a2df3db08cbe8809d1d435/tomli-2.4.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:5572e41282d5268eb09a697c89a7bee84fae66511f87533a6f88bd2f7b652da9", size = 148469, upload-time = "2026-01-11T11:21:46.873Z" }, + { url = "https://files.pythonhosted.org/packages/d6/c2/506e44cce89a8b1b1e047d64bd495c22c9f71f21e05f380f1a950dd9c217/tomli-2.4.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:551e321c6ba03b55676970b47cb1b73f14a0a4dce6a3e1a9458fd6d921d72e95", size = 236039, upload-time = "2026-01-11T11:21:48.503Z" }, + { url = "https://files.pythonhosted.org/packages/b3/40/e1b65986dbc861b7e986e8ec394598187fa8aee85b1650b01dd925ca0be8/tomli-2.4.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:5e3f639a7a8f10069d0e15408c0b96a2a828cfdec6fca05296ebcdcc28ca7c76", size = 243007, upload-time = "2026-01-11T11:21:49.456Z" }, + { url = "https://files.pythonhosted.org/packages/9c/6f/6e39ce66b58a5b7ae572a0f4352ff40c71e8573633deda43f6a379d56b3e/tomli-2.4.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:1b168f2731796b045128c45982d3a4874057626da0e2ef1fdd722848b741361d", size = 240875, upload-time = "2026-01-11T11:21:50.755Z" }, + { url = "https://files.pythonhosted.org/packages/aa/ad/cb089cb190487caa80204d503c7fd0f4d443f90b95cf4ef5cf5aa0f439b0/tomli-2.4.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:133e93646ec4300d651839d382d63edff11d8978be23da4cc106f5a18b7d0576", size = 246271, upload-time = "2026-01-11T11:21:51.81Z" }, + { url = "https://files.pythonhosted.org/packages/0b/63/69125220e47fd7a3a27fd0de0c6398c89432fec41bc739823bcc66506af6/tomli-2.4.0-cp311-cp311-win32.whl", hash = "sha256:b6c78bdf37764092d369722d9946cb65b8767bfa4110f902a1b2542d8d173c8a", size = 96770, upload-time = "2026-01-11T11:21:52.647Z" }, + { url = "https://files.pythonhosted.org/packages/1e/0d/a22bb6c83f83386b0008425a6cd1fa1c14b5f3dd4bad05e98cf3dbbf4a64/tomli-2.4.0-cp311-cp311-win_amd64.whl", hash = "sha256:d3d1654e11d724760cdb37a3d7691f0be9db5fbdaef59c9f532aabf87006dbaa", size = 107626, upload-time = "2026-01-11T11:21:53.459Z" }, + { url = "https://files.pythonhosted.org/packages/2f/6d/77be674a3485e75cacbf2ddba2b146911477bd887dda9d8c9dfb2f15e871/tomli-2.4.0-cp311-cp311-win_arm64.whl", hash = "sha256:cae9c19ed12d4e8f3ebf46d1a75090e4c0dc16271c5bce1c833ac168f08fb614", size = 94842, upload-time = "2026-01-11T11:21:54.831Z" }, + { url = "https://files.pythonhosted.org/packages/3c/43/7389a1869f2f26dba52404e1ef13b4784b6b37dac93bac53457e3ff24ca3/tomli-2.4.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:920b1de295e72887bafa3ad9f7a792f811847d57ea6b1215154030cf131f16b1", size = 154894, upload-time = "2026-01-11T11:21:56.07Z" }, + { url = "https://files.pythonhosted.org/packages/e9/05/2f9bf110b5294132b2edf13fe6ca6ae456204f3d749f623307cbb7a946f2/tomli-2.4.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:7d6d9a4aee98fac3eab4952ad1d73aee87359452d1c086b5ceb43ed02ddb16b8", size = 149053, upload-time = "2026-01-11T11:21:57.467Z" }, + { url = "https://files.pythonhosted.org/packages/e8/41/1eda3ca1abc6f6154a8db4d714a4d35c4ad90adc0bcf700657291593fbf3/tomli-2.4.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:36b9d05b51e65b254ea6c2585b59d2c4cb91c8a3d91d0ed0f17591a29aaea54a", size = 243481, upload-time = "2026-01-11T11:21:58.661Z" }, + { url = "https://files.pythonhosted.org/packages/d2/6d/02ff5ab6c8868b41e7d4b987ce2b5f6a51d3335a70aa144edd999e055a01/tomli-2.4.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1c8a885b370751837c029ef9bc014f27d80840e48bac415f3412e6593bbc18c1", size = 251720, upload-time = "2026-01-11T11:22:00.178Z" }, + { url = "https://files.pythonhosted.org/packages/7b/57/0405c59a909c45d5b6f146107c6d997825aa87568b042042f7a9c0afed34/tomli-2.4.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:8768715ffc41f0008abe25d808c20c3d990f42b6e2e58305d5da280ae7d1fa3b", size = 247014, upload-time = "2026-01-11T11:22:01.238Z" }, + { url = "https://files.pythonhosted.org/packages/2c/0e/2e37568edd944b4165735687cbaf2fe3648129e440c26d02223672ee0630/tomli-2.4.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:7b438885858efd5be02a9a133caf5812b8776ee0c969fea02c45e8e3f296ba51", size = 251820, upload-time = "2026-01-11T11:22:02.727Z" }, + { url = "https://files.pythonhosted.org/packages/5a/1c/ee3b707fdac82aeeb92d1a113f803cf6d0f37bdca0849cb489553e1f417a/tomli-2.4.0-cp312-cp312-win32.whl", hash = "sha256:0408e3de5ec77cc7f81960c362543cbbd91ef883e3138e81b729fc3eea5b9729", size = 97712, upload-time = "2026-01-11T11:22:03.777Z" }, + { url = "https://files.pythonhosted.org/packages/69/13/c07a9177d0b3bab7913299b9278845fc6eaaca14a02667c6be0b0a2270c8/tomli-2.4.0-cp312-cp312-win_amd64.whl", hash = "sha256:685306e2cc7da35be4ee914fd34ab801a6acacb061b6a7abca922aaf9ad368da", size = 108296, upload-time = "2026-01-11T11:22:04.86Z" }, + { url = "https://files.pythonhosted.org/packages/18/27/e267a60bbeeee343bcc279bb9e8fbed0cbe224bc7b2a3dc2975f22809a09/tomli-2.4.0-cp312-cp312-win_arm64.whl", hash = "sha256:5aa48d7c2356055feef06a43611fc401a07337d5b006be13a30f6c58f869e3c3", size = 94553, upload-time = "2026-01-11T11:22:05.854Z" }, + { url = "https://files.pythonhosted.org/packages/34/91/7f65f9809f2936e1f4ce6268ae1903074563603b2a2bd969ebbda802744f/tomli-2.4.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:84d081fbc252d1b6a982e1870660e7330fb8f90f676f6e78b052ad4e64714bf0", size = 154915, upload-time = "2026-01-11T11:22:06.703Z" }, + { url = "https://files.pythonhosted.org/packages/20/aa/64dd73a5a849c2e8f216b755599c511badde80e91e9bc2271baa7b2cdbb1/tomli-2.4.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:9a08144fa4cba33db5255f9b74f0b89888622109bd2776148f2597447f92a94e", size = 149038, upload-time = "2026-01-11T11:22:07.56Z" }, + { url = "https://files.pythonhosted.org/packages/9e/8a/6d38870bd3d52c8d1505ce054469a73f73a0fe62c0eaf5dddf61447e32fa/tomli-2.4.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:c73add4bb52a206fd0c0723432db123c0c75c280cbd67174dd9d2db228ebb1b4", size = 242245, upload-time = "2026-01-11T11:22:08.344Z" }, + { url = "https://files.pythonhosted.org/packages/59/bb/8002fadefb64ab2669e5b977df3f5e444febea60e717e755b38bb7c41029/tomli-2.4.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1fb2945cbe303b1419e2706e711b7113da57b7db31ee378d08712d678a34e51e", size = 250335, upload-time = "2026-01-11T11:22:09.951Z" }, + { url = "https://files.pythonhosted.org/packages/a5/3d/4cdb6f791682b2ea916af2de96121b3cb1284d7c203d97d92d6003e91c8d/tomli-2.4.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:bbb1b10aa643d973366dc2cb1ad94f99c1726a02343d43cbc011edbfac579e7c", size = 245962, upload-time = "2026-01-11T11:22:11.27Z" }, + { url = "https://files.pythonhosted.org/packages/f2/4a/5f25789f9a460bd858ba9756ff52d0830d825b458e13f754952dd15fb7bb/tomli-2.4.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:4cbcb367d44a1f0c2be408758b43e1ffb5308abe0ea222897d6bfc8e8281ef2f", size = 250396, upload-time = "2026-01-11T11:22:12.325Z" }, + { url = "https://files.pythonhosted.org/packages/aa/2f/b73a36fea58dfa08e8b3a268750e6853a6aac2a349241a905ebd86f3047a/tomli-2.4.0-cp313-cp313-win32.whl", hash = "sha256:7d49c66a7d5e56ac959cb6fc583aff0651094ec071ba9ad43df785abc2320d86", size = 97530, upload-time = "2026-01-11T11:22:13.865Z" }, + { url = "https://files.pythonhosted.org/packages/3b/af/ca18c134b5d75de7e8dc551c5234eaba2e8e951f6b30139599b53de9c187/tomli-2.4.0-cp313-cp313-win_amd64.whl", hash = "sha256:3cf226acb51d8f1c394c1b310e0e0e61fecdd7adcb78d01e294ac297dd2e7f87", size = 108227, upload-time = "2026-01-11T11:22:15.224Z" }, + { url = "https://files.pythonhosted.org/packages/22/c3/b386b832f209fee8073c8138ec50f27b4460db2fdae9ffe022df89a57f9b/tomli-2.4.0-cp313-cp313-win_arm64.whl", hash = "sha256:d20b797a5c1ad80c516e41bc1fb0443ddb5006e9aaa7bda2d71978346aeb9132", size = 94748, upload-time = "2026-01-11T11:22:16.009Z" }, + { url = "https://files.pythonhosted.org/packages/f3/c4/84047a97eb1004418bc10bdbcfebda209fca6338002eba2dc27cc6d13563/tomli-2.4.0-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:26ab906a1eb794cd4e103691daa23d95c6919cc2fa9160000ac02370cc9dd3f6", size = 154725, upload-time = "2026-01-11T11:22:17.269Z" }, + { url = "https://files.pythonhosted.org/packages/a8/5d/d39038e646060b9d76274078cddf146ced86dc2b9e8bbf737ad5983609a0/tomli-2.4.0-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:20cedb4ee43278bc4f2fee6cb50daec836959aadaf948db5172e776dd3d993fc", size = 148901, upload-time = "2026-01-11T11:22:18.287Z" }, + { url = "https://files.pythonhosted.org/packages/73/e5/383be1724cb30f4ce44983d249645684a48c435e1cd4f8b5cded8a816d3c/tomli-2.4.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:39b0b5d1b6dd03684b3fb276407ebed7090bbec989fa55838c98560c01113b66", size = 243375, upload-time = "2026-01-11T11:22:19.154Z" }, + { url = "https://files.pythonhosted.org/packages/31/f0/bea80c17971c8d16d3cc109dc3585b0f2ce1036b5f4a8a183789023574f2/tomli-2.4.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:a26d7ff68dfdb9f87a016ecfd1e1c2bacbe3108f4e0f8bcd2228ef9a766c787d", size = 250639, upload-time = "2026-01-11T11:22:20.168Z" }, + { url = "https://files.pythonhosted.org/packages/2c/8f/2853c36abbb7608e3f945d8a74e32ed3a74ee3a1f468f1ffc7d1cb3abba6/tomli-2.4.0-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:20ffd184fb1df76a66e34bd1b36b4a4641bd2b82954befa32fe8163e79f1a702", size = 246897, upload-time = "2026-01-11T11:22:21.544Z" }, + { url = "https://files.pythonhosted.org/packages/49/f0/6c05e3196ed5337b9fe7ea003e95fd3819a840b7a0f2bf5a408ef1dad8ed/tomli-2.4.0-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:75c2f8bbddf170e8effc98f5e9084a8751f8174ea6ccf4fca5398436e0320bc8", size = 254697, upload-time = "2026-01-11T11:22:23.058Z" }, + { url = "https://files.pythonhosted.org/packages/f3/f5/2922ef29c9f2951883525def7429967fc4d8208494e5ab524234f06b688b/tomli-2.4.0-cp314-cp314-win32.whl", hash = "sha256:31d556d079d72db7c584c0627ff3a24c5d3fb4f730221d3444f3efb1b2514776", size = 98567, upload-time = "2026-01-11T11:22:24.033Z" }, + { url = "https://files.pythonhosted.org/packages/7b/31/22b52e2e06dd2a5fdbc3ee73226d763b184ff21fc24e20316a44ccc4d96b/tomli-2.4.0-cp314-cp314-win_amd64.whl", hash = "sha256:43e685b9b2341681907759cf3a04e14d7104b3580f808cfde1dfdb60ada85475", size = 108556, upload-time = "2026-01-11T11:22:25.378Z" }, + { url = "https://files.pythonhosted.org/packages/48/3d/5058dff3255a3d01b705413f64f4306a141a8fd7a251e5a495e3f192a998/tomli-2.4.0-cp314-cp314-win_arm64.whl", hash = "sha256:3d895d56bd3f82ddd6faaff993c275efc2ff38e52322ea264122d72729dca2b2", size = 96014, upload-time = "2026-01-11T11:22:26.138Z" }, + { url = "https://files.pythonhosted.org/packages/b8/4e/75dab8586e268424202d3a1997ef6014919c941b50642a1682df43204c22/tomli-2.4.0-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:5b5807f3999fb66776dbce568cc9a828544244a8eb84b84b9bafc080c99597b9", size = 163339, upload-time = "2026-01-11T11:22:27.143Z" }, + { url = "https://files.pythonhosted.org/packages/06/e3/b904d9ab1016829a776d97f163f183a48be6a4deb87304d1e0116a349519/tomli-2.4.0-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:c084ad935abe686bd9c898e62a02a19abfc9760b5a79bc29644463eaf2840cb0", size = 159490, upload-time = "2026-01-11T11:22:28.399Z" }, + { url = "https://files.pythonhosted.org/packages/e3/5a/fc3622c8b1ad823e8ea98a35e3c632ee316d48f66f80f9708ceb4f2a0322/tomli-2.4.0-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:0f2e3955efea4d1cfbcb87bc321e00dc08d2bcb737fd1d5e398af111d86db5df", size = 269398, upload-time = "2026-01-11T11:22:29.345Z" }, + { url = "https://files.pythonhosted.org/packages/fd/33/62bd6152c8bdd4c305ad9faca48f51d3acb2df1f8791b1477d46ff86e7f8/tomli-2.4.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:0e0fe8a0b8312acf3a88077a0802565cb09ee34107813bba1c7cd591fa6cfc8d", size = 276515, upload-time = "2026-01-11T11:22:30.327Z" }, + { url = "https://files.pythonhosted.org/packages/4b/ff/ae53619499f5235ee4211e62a8d7982ba9e439a0fb4f2f351a93d67c1dd2/tomli-2.4.0-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:413540dce94673591859c4c6f794dfeaa845e98bf35d72ed59636f869ef9f86f", size = 273806, upload-time = "2026-01-11T11:22:32.56Z" }, + { url = "https://files.pythonhosted.org/packages/47/71/cbca7787fa68d4d0a9f7072821980b39fbb1b6faeb5f5cf02f4a5559fa28/tomli-2.4.0-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:0dc56fef0e2c1c470aeac5b6ca8cc7b640bb93e92d9803ddaf9ea03e198f5b0b", size = 281340, upload-time = "2026-01-11T11:22:33.505Z" }, + { url = "https://files.pythonhosted.org/packages/f5/00/d595c120963ad42474cf6ee7771ad0d0e8a49d0f01e29576ee9195d9ecdf/tomli-2.4.0-cp314-cp314t-win32.whl", hash = "sha256:d878f2a6707cc9d53a1be1414bbb419e629c3d6e67f69230217bb663e76b5087", size = 108106, upload-time = "2026-01-11T11:22:34.451Z" }, + { url = "https://files.pythonhosted.org/packages/de/69/9aa0c6a505c2f80e519b43764f8b4ba93b5a0bbd2d9a9de6e2b24271b9a5/tomli-2.4.0-cp314-cp314t-win_amd64.whl", hash = "sha256:2add28aacc7425117ff6364fe9e06a183bb0251b03f986df0e78e974047571fd", size = 120504, upload-time = "2026-01-11T11:22:35.764Z" }, + { url = "https://files.pythonhosted.org/packages/b3/9f/f1668c281c58cfae01482f7114a4b88d345e4c140386241a1a24dcc9e7bc/tomli-2.4.0-cp314-cp314t-win_arm64.whl", hash = "sha256:2b1e3b80e1d5e52e40e9b924ec43d81570f0e7d09d11081b797bc4692765a3d4", size = 99561, upload-time = "2026-01-11T11:22:36.624Z" }, + { url = "https://files.pythonhosted.org/packages/23/d1/136eb2cb77520a31e1f64cbae9d33ec6df0d78bdf4160398e86eec8a8754/tomli-2.4.0-py3-none-any.whl", hash = "sha256:1f776e7d669ebceb01dee46484485f43a4048746235e683bcdffacdf1fb4785a", size = 14477, upload-time = "2026-01-11T11:22:37.446Z" }, +] + +[[package]] +name = "zipp" +version = "3.23.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/e3/02/0f2892c661036d50ede074e376733dca2ae7c6eb617489437771209d4180/zipp-3.23.0.tar.gz", hash = "sha256:a07157588a12518c9d4034df3fbbee09c814741a33ff63c05fa29d26a2404166", size = 25547, upload-time = "2025-06-08T17:06:39.4Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/2e/54/647ade08bf0db230bfea292f893923872fd20be6ac6f53b2b936ba839d75/zipp-3.23.0-py3-none-any.whl", hash = "sha256:071652d6115ed432f5ce1d34c336c0adfd6a884660d1e9712a256d3d3bd4b14e", size = 10276, upload-time = "2025-06-08T17:06:38.034Z" }, +] From fe8305a6a8c20e21a0ce48e8411af7a8771fcaeb Mon Sep 17 00:00:00 2001 From: Casu Al Snek Date: Sun, 22 Feb 2026 12:49:19 +0545 Subject: [PATCH 2/8] fix: Make PKGBUILD Buildable and ensure all mode of installation use same locations --- README.md | 12 +-- arch/hp-wmi-omen/PKGBUILD | 32 +++--- arch/omen-fan-control/PKGBUILD | 29 +++--- src/omen_fan_control/data/driver/Makefile | 11 --- src/omen_fan_control/data/driver/dkms.conf | 10 +- .../data/driver/hooks/90-hp-wmi-omen.hook | 2 +- .../data/driver/hooks/99-hp-wmi-omen.install | 5 +- .../data/driver/hooks/zz-hp-wmi-omen | 5 +- .../data/driver/hp-wmi-omen/Makefile | 1 + .../data/driver/{ => hp-wmi-omen}/hp-wmi.c | 0 .../driver/{ => hp-wmi-omen}/hp-wmi.c.orig | 0 .../data/driver/install_driver.sh | 97 ++++++------------- 12 files changed, 82 insertions(+), 122 deletions(-) delete mode 100644 src/omen_fan_control/data/driver/Makefile create mode 100644 src/omen_fan_control/data/driver/hp-wmi-omen/Makefile rename src/omen_fan_control/data/driver/{ => hp-wmi-omen}/hp-wmi.c (100%) rename src/omen_fan_control/data/driver/{ => hp-wmi-omen}/hp-wmi.c.orig (100%) diff --git a/README.md b/README.md index dccab6b..5d30c4c 100644 --- a/README.md +++ b/README.md @@ -53,15 +53,15 @@ sudo omen-fan-control-gui Two packages: the **DKMS kernel module** (optional; persists across kernel updates) and the **Python app**. -1. **Kernel module (DKMS)** – from repo: +1. **Kernel module (DKMS)** – run from the package dir (makepkg needs PKGBUILD in cwd): ```bash - cd omen-fan-control/arch/hp-wmi-omen && makepkg -si + cd omen-fan-control/arch/hp-wmi-omen && makepkg -sf + sudo pacman -U hp-wmi-omen-dkms-*.pkg.tar.zst ``` - This installs `hp-wmi-omen-dkms`. Alternatively, install the driver from the app (see Option C). -2. **Python application** – from repo root: +2. **Python application** – run from the package dir: ```bash - makepkg -p arch/omen-fan-control/PKGBUILD -sf - sudo pacman -U omen-fan-control-*.pkg.tar.zst + cd omen-fan-control/arch/omen-fan-control && makepkg -sf + sudo pacman -U omen-fan-control-*.pkg.tar.zst ``` Driver data is installed under `/usr/share/omen-fan-control`; the app uses it when you run `install-patch permanent` (e.g. for calibration-based patching). Set `OMEN_FAN_CONTROL_DIR=/usr/share/omen-fan-control` if not using the provided `profile.d` snippet. diff --git a/arch/hp-wmi-omen/PKGBUILD b/arch/hp-wmi-omen/PKGBUILD index 939570a..73907d1 100644 --- a/arch/hp-wmi-omen/PKGBUILD +++ b/arch/hp-wmi-omen/PKGBUILD @@ -1,5 +1,4 @@ # DKMS kernel module: patched hp-wmi for HP Omen/Victus fan control (Linux < 6.20) -# Reference: https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/commit/?h=for-next&id=46be1453e6e61884b4840a768d1e8ffaf01a4c1c _pkgbase=hp-wmi-omen pkgname="${_pkgbase}-dkms" pkgver=1.0 @@ -8,23 +7,32 @@ pkgdesc="Patched hp-wmi driver for HP Omen/Victus fan control (DKMS; for kernels url="https://github.com/arfelious/omen-fan-control" license=("GPL") arch=("x86_64") -depends=("dkms" "linux-headers") +depends=('glibc' 'dkms') makedepends=() conflicts=() provides=("hp-wmi-omen") +source=("PKGBUILD") +sha256sums=("SKIP") -source=( - "../../src/omen_fan_control/data/driver/hp-wmi.c" - "../../src/omen_fan_control/data/driver/hp-wmi.c.orig" - "../../src/omen_fan_control/data/driver/Makefile" - "../../src/omen_fan_control/data/driver/dkms.conf" -) -sha256sums=("SKIP" "SKIP" "SKIP" "SKIP") +prepare() { + # Copy driver from repo + + local reporoot + if [[ -f "$startdir/src/omen_fan_control/data/driver/hp-wmi-omen/hp-wmi.c" ]]; then + reporoot="$startdir" + else + reporoot="$startdir/../.." + fi + local driver="$reporoot/src/omen_fan_control/data/driver" + cp -f "$driver/dkms.conf" "$srcdir/" + cp -dr --no-preserve=ownership "$driver/hp-wmi-omen" "$srcdir/" +} package() { local dkms_dir="/usr/src/${_pkgbase}-${pkgver}" - install -Dm644 hp-wmi.c "${pkgdir}${dkms_dir}/hp-wmi.c" - install -Dm644 hp-wmi.c.orig "${pkgdir}${dkms_dir}/hp-wmi.c.orig" - install -Dm644 Makefile "${pkgdir}${dkms_dir}/Makefile" install -Dm644 dkms.conf "${pkgdir}${dkms_dir}/dkms.conf" + sed -e "s/@PKGNAME@/${_pkgbase}/g" \ + -e "s/@PKGVER@/${pkgver}/g" \ + -i "${pkgdir}${dkms_dir}/dkms.conf" + cp -dr --no-preserve=ownership "./hp-wmi-omen" "${pkgdir}${dkms_dir}/src" } diff --git a/arch/omen-fan-control/PKGBUILD b/arch/omen-fan-control/PKGBUILD index b428dbb..1f7c2bd 100644 --- a/arch/omen-fan-control/PKGBUILD +++ b/arch/omen-fan-control/PKGBUILD @@ -10,15 +10,19 @@ arch=("any") depends=("python-click" "python-pyqt6") makedepends=("python-build" "python-installer" "python-hatchling") optdepends=("hp-wmi-omen-dkms: persist patched driver across kernel updates") -# One file so makepkg sets srcdir; prepare() copies rest from repo (run from repo root: makepkg -p arch/omen-fan-control/PKGBUILD) -source=("../../pyproject.toml") +source=("PKGBUILD") sha256sums=("SKIP") prepare() { - local repo_root - repo_root="$(cd "${startdir}/../.." && pwd)" - cp -f "$repo_root/README.md" "$repo_root/LICENSE.md" "$srcdir/" 2>/dev/null || true - cp -r "$repo_root/src" "$srcdir/" + local reporoot + if [[ -f "$startdir/pyproject.toml" ]]; then + reporoot="$startdir" + else + reporoot="$startdir/../.." + fi + cp -f "$reporoot/pyproject.toml" "$srcdir/" + cp -f "$reporoot/README.md" "$reporoot/LICENSE.md" "$srcdir/" 2>/dev/null || true + cp -r "$reporoot/src" "$srcdir/" } build() { @@ -31,14 +35,13 @@ package() { whl=$(echo "$srcdir"/dist/omen_fan_control*.whl) python -m installer --compile-bytecode=0 -d "$pkgdir" "$whl" - # Driver data for "install-patch permanent" (OMEN_FAN_CONTROL_DIR used by app) + # Driver data for "install-patch permanent" (same layout as hp-wmi-omen-dkms: dkms.conf + hp-wmi-omen/) + local driver="$srcdir/src/omen_fan_control/data/driver" + install -Dm644 "$driver/dkms.conf" "$pkgdir/usr/share/omen-fan-control/driver/dkms.conf" + cp -dr --no-preserve=ownership "$driver/hp-wmi-omen" "$pkgdir/usr/share/omen-fan-control/driver/" + install -Dm755 "$driver/install_driver.sh" "$pkgdir/usr/share/omen-fan-control/driver/install_driver.sh" install -dm755 "$pkgdir/usr/share/omen-fan-control/driver/hooks" - install -Dm644 "$srcdir/src/omen_fan_control/data/driver/hp-wmi.c" "$pkgdir/usr/share/omen-fan-control/driver/hp-wmi.c" - install -Dm644 "$srcdir/src/omen_fan_control/data/driver/hp-wmi.c.orig" "$pkgdir/usr/share/omen-fan-control/driver/hp-wmi.c.orig" - install -Dm644 "$srcdir/src/omen_fan_control/data/driver/Makefile" "$pkgdir/usr/share/omen-fan-control/driver/Makefile" - install -Dm644 "$srcdir/src/omen_fan_control/data/driver/dkms.conf" "$pkgdir/usr/share/omen-fan-control/driver/dkms.conf" - install -Dm755 "$srcdir/src/omen_fan_control/data/driver/install_driver.sh" "$pkgdir/usr/share/omen-fan-control/driver/install_driver.sh" - for f in "$srcdir/src/omen_fan_control/data/driver/hooks/"*; do + for f in "$driver/hooks/"*; do [[ -f "$f" ]] && install -Dm644 "$f" "$pkgdir/usr/share/omen-fan-control/driver/hooks/$(basename "$f")" done diff --git a/src/omen_fan_control/data/driver/Makefile b/src/omen_fan_control/data/driver/Makefile deleted file mode 100644 index 04ddfd0..0000000 --- a/src/omen_fan_control/data/driver/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -obj-m += hp-wmi.o - -all: - make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules - -clean: - make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean - -install: - sudo cp hp-wmi.ko /lib/modules/$(shell uname -r)/kernel/drivers/platform/x86/hp/hp-wmi.ko.xz - sudo depmod -a diff --git a/src/omen_fan_control/data/driver/dkms.conf b/src/omen_fan_control/data/driver/dkms.conf index 88e4856..65c3149 100644 --- a/src/omen_fan_control/data/driver/dkms.conf +++ b/src/omen_fan_control/data/driver/dkms.conf @@ -1,6 +1,8 @@ -PACKAGE_NAME="hp-wmi-omen" -PACKAGE_VERSION="1.0" -MAKE[0]="make -C /lib/modules/${kernelver}/build M=${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build modules" +PACKAGE_NAME="@PKGNAME@" +PACKAGE_VERSION="@PKGVER@" +MAKE[0]="make -C $kernel_source_dir M=$dkms_tree/$module/$module_version/build/src/hp-wmi-omen EXTRA_CFLAGS='' modules" +CLEAN="rm -f src/hp-wmi-omen/hp-wmi.ko src/hp-wmi-omen/*.o || true" BUILT_MODULE_NAME[0]="hp-wmi" -DEST_MODULE_LOCATION[0]="/updates" +BUILT_MODULE_LOCATION[0]="src/hp-wmi-omen/" +DEST_MODULE_LOCATION[0]="/kernel/drivers/platform/x86/hp" AUTOINSTALL="yes" diff --git a/src/omen_fan_control/data/driver/hooks/90-hp-wmi-omen.hook b/src/omen_fan_control/data/driver/hooks/90-hp-wmi-omen.hook index 3e149b9..8c31a5f 100644 --- a/src/omen_fan_control/data/driver/hooks/90-hp-wmi-omen.hook +++ b/src/omen_fan_control/data/driver/hooks/90-hp-wmi-omen.hook @@ -10,6 +10,6 @@ Target = linux-hardened [Action] Description = Rebuilding hp-wmi-omen module... When = PostTransaction -Exec = /bin/bash -c 'cd /usr/src/hp-wmi-omen && make clean && make && for kver in /lib/modules/*/; do kver=$(basename "$kver"); if [ -d "/lib/modules/$kver/build" ]; then make -C /lib/modules/$kver/build M=/usr/src/hp-wmi-omen modules && install -Dm644 /usr/src/hp-wmi-omen/hp-wmi.ko /lib/modules/$kver/kernel/drivers/platform/x86/hp/hp-wmi.ko; fi; done; depmod -a' +Exec = /bin/bash -c 'SRC=/usr/src/hp-wmi-omen-1.0/src/hp-wmi-omen; [ -d "$SRC" ] || exit 0; for kver in /lib/modules/*/; do kver=$(basename "$kver"); [ -d "/lib/modules/$kver/build" ] || continue; (cd "$SRC" && make -C /lib/modules/$kver/build M="$SRC" modules) && install -Dm644 "$SRC/hp-wmi.ko" "/lib/modules/$kver/kernel/drivers/platform/x86/hp/hp-wmi.ko"; done; depmod -a' Depends = make Depends = linux-headers diff --git a/src/omen_fan_control/data/driver/hooks/99-hp-wmi-omen.install b/src/omen_fan_control/data/driver/hooks/99-hp-wmi-omen.install index 5b15a23..a97de5f 100644 --- a/src/omen_fan_control/data/driver/hooks/99-hp-wmi-omen.install +++ b/src/omen_fan_control/data/driver/hooks/99-hp-wmi-omen.install @@ -1,10 +1,10 @@ #!/bin/bash # HP Omen Fan Control - Kernel install hook for Fedora/RHEL -# Installed to /etc/kernel/install.d/99-hp-wmi-omen.install +# Builds from /usr/src/hp-wmi-omen-1.0/src/hp-wmi-omen (same as DKMS package layout) COMMAND="$1" KERNEL_VERSION="$2" -SOURCE_DIR="/usr/src/hp-wmi-omen" +SOURCE_DIR="/usr/src/hp-wmi-omen-1.0/src/hp-wmi-omen" if [ "$COMMAND" != "add" ]; then exit 0 @@ -16,7 +16,6 @@ if [ ! -d "$SOURCE_DIR" ]; then fi echo "Building hp-wmi-omen for kernel $KERNEL_VERSION..." - cd "$SOURCE_DIR" make clean || true make -C "/lib/modules/$KERNEL_VERSION/build" M="$SOURCE_DIR" modules diff --git a/src/omen_fan_control/data/driver/hooks/zz-hp-wmi-omen b/src/omen_fan_control/data/driver/hooks/zz-hp-wmi-omen index a151f6e..b16dc94 100644 --- a/src/omen_fan_control/data/driver/hooks/zz-hp-wmi-omen +++ b/src/omen_fan_control/data/driver/hooks/zz-hp-wmi-omen @@ -1,11 +1,11 @@ #!/bin/bash # HP Omen Fan Control - Kernel update hook for Debian/Ubuntu -# Installed to /etc/kernel/postinst.d/zz-hp-wmi-omen +# Builds from /usr/src/hp-wmi-omen-1.0/src/hp-wmi-omen (same as DKMS package layout) set -e KERNEL_VERSION="$1" -SOURCE_DIR="/usr/src/hp-wmi-omen" +SOURCE_DIR="/usr/src/hp-wmi-omen-1.0/src/hp-wmi-omen" if [ ! -d "$SOURCE_DIR" ]; then echo "hp-wmi-omen source not found, skipping..." @@ -13,7 +13,6 @@ if [ ! -d "$SOURCE_DIR" ]; then fi echo "Building hp-wmi-omen for kernel $KERNEL_VERSION..." - cd "$SOURCE_DIR" make clean || true make -C "/lib/modules/$KERNEL_VERSION/build" M="$SOURCE_DIR" modules diff --git a/src/omen_fan_control/data/driver/hp-wmi-omen/Makefile b/src/omen_fan_control/data/driver/hp-wmi-omen/Makefile new file mode 100644 index 0000000..9af312a --- /dev/null +++ b/src/omen_fan_control/data/driver/hp-wmi-omen/Makefile @@ -0,0 +1 @@ +obj-m += hp-wmi.o diff --git a/src/omen_fan_control/data/driver/hp-wmi.c b/src/omen_fan_control/data/driver/hp-wmi-omen/hp-wmi.c similarity index 100% rename from src/omen_fan_control/data/driver/hp-wmi.c rename to src/omen_fan_control/data/driver/hp-wmi-omen/hp-wmi.c diff --git a/src/omen_fan_control/data/driver/hp-wmi.c.orig b/src/omen_fan_control/data/driver/hp-wmi-omen/hp-wmi.c.orig similarity index 100% rename from src/omen_fan_control/data/driver/hp-wmi.c.orig rename to src/omen_fan_control/data/driver/hp-wmi-omen/hp-wmi.c.orig diff --git a/src/omen_fan_control/data/driver/install_driver.sh b/src/omen_fan_control/data/driver/install_driver.sh index ca65eee..3ab5309 100755 --- a/src/omen_fan_control/data/driver/install_driver.sh +++ b/src/omen_fan_control/data/driver/install_driver.sh @@ -2,13 +2,13 @@ set -e # HP Omen Fan Control - Permanent Driver Installation -# Hybrid approach: Uses DKMS if available, otherwise installs kernel hooks +# Uses same layout as DKMS package: /usr/src/hp-wmi-omen-1.0/{dkms.conf, src/Makefile, src/hp-wmi-omen/} SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" DKMS_NAME="hp-wmi-omen" DKMS_VERSION="1.0" DKMS_SRC="/usr/src/${DKMS_NAME}-${DKMS_VERSION}" -HOOK_SRC_DIR="/usr/src/${DKMS_NAME}" +BUILD_DIR="${DKMS_SRC}/src/hp-wmi-omen" detect_distro() { if [ -f /etc/os-release ]; then @@ -27,54 +27,39 @@ detect_distro() { install_with_dkms() { echo "Installing with DKMS..." - - # Remove old DKMS module if exists if dkms status | grep -q "${DKMS_NAME}"; then echo "Removing old DKMS module..." sudo dkms remove "${DKMS_NAME}/${DKMS_VERSION}" --all 2>/dev/null || true fi - - # Create DKMS source directory sudo rm -rf "$DKMS_SRC" - sudo mkdir -p "$DKMS_SRC" - - # Copy source files - sudo cp "$SCRIPT_DIR/hp-wmi.c" "$DKMS_SRC/" - sudo cp "$SCRIPT_DIR/Makefile" "$DKMS_SRC/" + sudo mkdir -p "${DKMS_SRC}/src" sudo cp "$SCRIPT_DIR/dkms.conf" "$DKMS_SRC/" - - # Backup existing drivers + # Same as PKGBUILD: replace placeholders so DKMS finds the module + sudo sed -e "s/@PKGNAME@/${DKMS_NAME}/g" -e "s/@PKGVER@/${DKMS_VERSION}/g" -i "$DKMS_SRC/dkms.conf" + sudo cp "$SCRIPT_DIR/src/Makefile" "$DKMS_SRC/src/" + sudo cp -dr --no-preserve=ownership "$SCRIPT_DIR/hp-wmi-omen" "$DKMS_SRC/src/" backup_drivers - - # Add, build, and install via DKMS sudo dkms add -m "${DKMS_NAME}" -v "${DKMS_VERSION}" sudo dkms build -m "${DKMS_NAME}" -v "${DKMS_VERSION}" sudo dkms install -m "${DKMS_NAME}" -v "${DKMS_VERSION}" - echo "DKMS installation complete!" } install_with_hooks() { local distro="$1" echo "Installing with kernel hooks (distro: $distro)..." - - # Build module for current kernel first - make -C "$SCRIPT_DIR" - - # Backup and install for current kernel + sudo rm -rf "$DKMS_SRC" + sudo mkdir -p "${DKMS_SRC}/src" + sudo cp "$SCRIPT_DIR/dkms.conf" "$DKMS_SRC/" + sudo sed -e "s/@PKGNAME@/${DKMS_NAME}/g" -e "s/@PKGVER@/${DKMS_VERSION}/g" -i "$DKMS_SRC/dkms.conf" + sudo cp "$SCRIPT_DIR/src/Makefile" "$DKMS_SRC/src/" + sudo cp -dr --no-preserve=ownership "$SCRIPT_DIR/hp-wmi-omen" "$DKMS_SRC/src/" + cd "$BUILD_DIR" + make -C "/lib/modules/$(uname -r)/build" M="$(pwd)" modules backup_drivers - DEST_DIR="/lib/modules/$(uname -r)/kernel/drivers/platform/x86/hp" sudo mkdir -p "$DEST_DIR" - sudo install -m 644 "$SCRIPT_DIR/hp-wmi.ko" "$DEST_DIR/hp-wmi.ko" - - # Copy source for future builds - sudo rm -rf "$HOOK_SRC_DIR" - sudo mkdir -p "$HOOK_SRC_DIR" - sudo cp "$SCRIPT_DIR/hp-wmi.c" "$HOOK_SRC_DIR/" - sudo cp "$SCRIPT_DIR/Makefile" "$HOOK_SRC_DIR/" - - # Install appropriate hook based on distro + sudo install -m 644 hp-wmi.ko "$DEST_DIR/hp-wmi.ko" case "$distro" in arch|manjaro|endeavouros|garuda) echo "Installing Arch Linux pacman hook..." @@ -82,53 +67,40 @@ install_with_hooks() { sudo cp "$SCRIPT_DIR/hooks/90-hp-wmi-omen.hook" /etc/pacman.d/hooks/ ;; debian|ubuntu|linuxmint|pop) - echo "Installing Debian/Ubuntu kernel hook..." sudo install -m 755 "$SCRIPT_DIR/hooks/zz-hp-wmi-omen" /etc/kernel/postinst.d/ ;; fedora|rhel|centos|rocky|almalinux) - echo "Installing Fedora/RHEL kernel hook..." sudo mkdir -p /etc/kernel/install.d sudo install -m 755 "$SCRIPT_DIR/hooks/99-hp-wmi-omen.install" /etc/kernel/install.d/ ;; *) - echo "Warning: Unknown distro '$distro'. No kernel hook installed." - echo "The module is installed for the current kernel only." - echo "You may need to manually reinstall after kernel updates." + echo "Warning: Unknown distro. Module installed for current kernel only." ;; esac - - make -C "$SCRIPT_DIR" clean + make clean || true echo "Hook-based installation complete!" } backup_drivers() { echo "Backing up existing drivers..." - # Check both standard path and updates (DKMS) path find "/lib/modules/$(uname -r)/kernel/drivers/platform/x86/hp" "/lib/modules/$(uname -r)/updates" -name "hp-wmi.ko*" 2>/dev/null | while read -r OLD_DRIVER; do - if [[ "$OLD_DRIVER" == *"$SCRIPT_DIR"* ]]; then continue; fi - # Avoid double-backing up (skip .bak files entirely) - if [[ "$OLD_DRIVER" != *".bak" ]]; then - # Check if a .bak ALREADY exists for this driver path. - # If so, do NOT backup again - if [ ! -f "${OLD_DRIVER}.bak" ]; then - echo "Backing up: $OLD_DRIVER" - sudo cp "$OLD_DRIVER" "${OLD_DRIVER}.bak" - else - echo "Clean backup already exists for: $OLD_DRIVER (Skipping Backup)" - fi - - # Important: Remove the conflicting module so depmod picks the new one - echo "Removing conflicting module: $OLD_DRIVER" - sudo rm -f "$OLD_DRIVER" + [[ "$OLD_DRIVER" == *".bak" ]] && continue + # If a .bak already exists for this driver, do not overwrite + if [ ! -f "${OLD_DRIVER}.bak" ]; then + echo "Backing up: $OLD_DRIVER" + sudo cp "$OLD_DRIVER" "${OLD_DRIVER}.bak" + else + echo "Clean backup already exists for: $OLD_DRIVER (Skipping Backup)" fi + echo "Removing conflicting module: $OLD_DRIVER" + sudo rm -f "$OLD_DRIVER" done } reload_driver() { echo "Reloading driver..." sudo depmod -a - if sudo modprobe -r hp-wmi 2>/dev/null; then sudo modprobe hp-wmi echo "Driver reloaded successfully!" @@ -138,7 +110,6 @@ reload_driver() { } update_initramfs() { - echo "Updating initramfs..." if command -v update-initramfs >/dev/null; then sudo update-initramfs -u elif command -v mkinitcpio >/dev/null; then @@ -148,37 +119,25 @@ update_initramfs() { fi } -# Main installation logic main() { echo "=== HP Omen Fan Control - Permanent Installation ===" - DISTRO=$(detect_distro) echo "Detected distro: $DISTRO" - FORCE_HOOKS=0 for arg in "$@"; do - if [ "$arg" == "--no-dkms" ]; then - FORCE_HOOKS=1 - fi + [[ "$arg" == "--no-dkms" ]] && FORCE_HOOKS=1 done - if [ "$FORCE_HOOKS" -eq 1 ]; then - echo "Forcing kernel hooks installation (--no-dkms passed)." install_with_hooks "$DISTRO" elif command -v dkms >/dev/null 2>&1; then - echo "DKMS is available." install_with_dkms else - echo "DKMS not found. Using kernel hooks fallback." install_with_hooks "$DISTRO" fi - reload_driver update_initramfs - echo "" echo "=== Installation Complete ===" - echo "The patched hp-wmi driver is now installed and will persist across reboots." } main "$@" \ No newline at end of file From 412a3e276b0158cd21a38625e8bfac48b45b9c1d Mon Sep 17 00:00:00 2001 From: Casu Al Snek Date: Sun, 22 Feb 2026 18:52:21 +0545 Subject: [PATCH 3/8] chore: Sync changes from upstream --- src/omen_fan_control/cli.py | 9 +++++++ src/omen_fan_control/gui.py | 50 ++++++++++--------------------------- 2 files changed, 22 insertions(+), 37 deletions(-) diff --git a/src/omen_fan_control/cli.py b/src/omen_fan_control/cli.py index 98ba1a3..4ebd993 100644 --- a/src/omen_fan_control/cli.py +++ b/src/omen_fan_control/cli.py @@ -447,6 +447,15 @@ def remove_service_cmd(): click.echo(msg) +@service.command(name="restart") +def restart_service_cmd(): + """Restart the background service""" + controller = get_controller() + click.echo("Restarting background service...") + success, msg = controller.restart_service() + click.echo(msg) + + @service.command(name="status") def service_status_cmd(): """Check service status""" diff --git a/src/omen_fan_control/gui.py b/src/omen_fan_control/gui.py index 391fa8e..97c0aae 100644 --- a/src/omen_fan_control/gui.py +++ b/src/omen_fan_control/gui.py @@ -901,13 +901,11 @@ def init_options_page(self): self.svc_btn.setStyleSheet("background-color: #2e7d32;") svc_layout.addWidget(self.svc_btn) - self.svc_restart_btn = QPushButton("Restart Service") self.svc_restart_btn.setFixedWidth(150) self.svc_restart_btn.setStyleSheet("background-color: #f57c00; color: white;") self.svc_restart_btn.clicked.connect(self.restart_service_request) self.svc_restart_btn.setVisible(self.controller.is_service_installed()) - svc_layout.addWidget(self.svc_restart_btn) svc_layout.addStretch() @@ -1048,17 +1046,6 @@ def apply_fan_mode(self): self.manual_unsaved_lbl.setVisible(False) self.curve_unsaved_lbl.setVisible(False) - self.manual_unsaved_lbl.setVisible(False) - self.curve_unsaved_lbl.setVisible(False) - - # If service is running, we just save config and let service handle it - if self.controller.is_service_running(): - self.status_label.setText(f"Settings saved. Service will apply {mode} mode.") - # Ensure local loop is stopped - if hasattr(self, 'curve_timer'): - self.curve_timer.stop() - return - if mode == "auto": self.controller.set_fan_mode("auto") self.status_label.setText("Set mode to Auto") @@ -1086,11 +1073,6 @@ def start_curve_loop(self): self.curve_timer = QTimer() self.curve_timer.timeout.connect(self.apply_curve_step) - # If service is running, do not run local loop - if self.controller.is_service_running(): - self.curve_timer.stop() - return - if self.mode_combo.currentText() == "Curve": self.curve_timer.start(2000) else: @@ -1294,10 +1276,8 @@ def toggle_service(self): def check_service_status(self): installed = self.controller.is_service_installed() - - if hasattr(self, 'svc_restart_btn'): + if hasattr(self, "svc_restart_btn"): self.svc_restart_btn.setVisible(installed) - if not installed: self.svc_status_label.setText("Service: Not Installed") self.svc_status_label.setStyleSheet("color: #888;") @@ -1305,17 +1285,14 @@ def check_service_status(self): running = self.controller.is_service_running() if running: self.svc_status_label.setText("Service: Active") - self.svc_status_label.setStyleSheet("color: #4caf50; font-weight: bold;") # Green - - # Stop local loop if service is running - if hasattr(self, 'curve_timer') and self.curve_timer.isActive(): - self.curve_timer.stop() + self.svc_status_label.setStyleSheet("color: #4caf50; font-weight: bold;") # Green else: self.svc_status_label.setText("Service: Inactive") - self.svc_status_label.setStyleSheet("color: #ff9800; font-weight: bold;") # Orange - - # Resume local loop if in Curve mode and service is not running - if self.mode_combo.currentText() == "Curve" and not (hasattr(self, 'curve_timer') and self.curve_timer.isActive()): + self.svc_status_label.setStyleSheet("color: #ff9800; font-weight: bold;") # Orange + # Resume local curve loop if in Curve mode and timer not already active + if self.mode_combo.currentText() == "Curve" and not ( + hasattr(self, "curve_timer") and self.curve_timer.isActive() + ): self.start_curve_loop() def restart_service_request(self): @@ -1323,7 +1300,6 @@ def restart_service_request(self): self.svc_status_label.setStyleSheet("color: #ff9800; font-weight: bold;") self.svc_restart_btn.setEnabled(False) self.svc_btn.setEnabled(False) - self.restart_thread = WorkerThread(self.controller.restart_service) self.restart_thread.finished.connect(self.on_svc_restart_finished) self.restart_thread.start() @@ -1333,12 +1309,12 @@ def on_svc_restart_finished(self, result): self.svc_btn.setEnabled(True) success, msg = result if success: - self.check_service_status() - QMessageBox.information(self, "Service", "Service successfully restarted.") + self.check_service_status() + QMessageBox.information(self, "Service", "Service successfully restarted.") else: - self.svc_status_label.setText("Restart Failed") - self.svc_status_label.setStyleSheet("color: #d63333; font-weight: bold;") - QMessageBox.critical(self, "Service Error", msg) + self.svc_status_label.setText("Restart Failed") + self.svc_status_label.setStyleSheet("color: #d63333; font-weight: bold;") + QMessageBox.critical(self, "Service Error", msg) def toggle_stress_test(self, checked): if checked: @@ -1402,4 +1378,4 @@ def main(): if __name__ == "__main__": - main() + main() \ No newline at end of file From df51aa32d90163c6407cb637baa1194e52d558f5 Mon Sep 17 00:00:00 2001 From: Casu Al Snek Date: Sun, 22 Feb 2026 19:02:08 +0545 Subject: [PATCH 4/8] fix: Try fixing DKMS build issues --- arch/hp-wmi-omen/PKGBUILD | 10 ++++++---- src/omen_fan_control/data/driver/dkms.conf | 3 +-- src/omen_fan_control/data/driver/src/Makefile | 1 + 3 files changed, 8 insertions(+), 6 deletions(-) create mode 100644 src/omen_fan_control/data/driver/src/Makefile diff --git a/arch/hp-wmi-omen/PKGBUILD b/arch/hp-wmi-omen/PKGBUILD index 73907d1..770227c 100644 --- a/arch/hp-wmi-omen/PKGBUILD +++ b/arch/hp-wmi-omen/PKGBUILD @@ -15,8 +15,7 @@ source=("PKGBUILD") sha256sums=("SKIP") prepare() { - # Copy driver from repo - + # Copy driver from repo (same layout as betel: dkms.conf + src/Makefile + src/hp-wmi-omen/) local reporoot if [[ -f "$startdir/src/omen_fan_control/data/driver/hp-wmi-omen/hp-wmi.c" ]]; then reporoot="$startdir" @@ -25,7 +24,9 @@ prepare() { fi local driver="$reporoot/src/omen_fan_control/data/driver" cp -f "$driver/dkms.conf" "$srcdir/" - cp -dr --no-preserve=ownership "$driver/hp-wmi-omen" "$srcdir/" + mkdir -p "$srcdir/src" + cp -f "$driver/src/Makefile" "$srcdir/src/" + cp -dr --no-preserve=ownership "$driver/hp-wmi-omen" "$srcdir/src/" } package() { @@ -34,5 +35,6 @@ package() { sed -e "s/@PKGNAME@/${_pkgbase}/g" \ -e "s/@PKGVER@/${pkgver}/g" \ -i "${pkgdir}${dkms_dir}/dkms.conf" - cp -dr --no-preserve=ownership "./hp-wmi-omen" "${pkgdir}${dkms_dir}/src" + install -Dm644 src/Makefile "${pkgdir}${dkms_dir}/src/Makefile" + cp -dr --no-preserve=ownership "./src/hp-wmi-omen" "${pkgdir}${dkms_dir}/src" } diff --git a/src/omen_fan_control/data/driver/dkms.conf b/src/omen_fan_control/data/driver/dkms.conf index 65c3149..7715f87 100644 --- a/src/omen_fan_control/data/driver/dkms.conf +++ b/src/omen_fan_control/data/driver/dkms.conf @@ -1,7 +1,6 @@ PACKAGE_NAME="@PKGNAME@" PACKAGE_VERSION="@PKGVER@" -MAKE[0]="make -C $kernel_source_dir M=$dkms_tree/$module/$module_version/build/src/hp-wmi-omen EXTRA_CFLAGS='' modules" -CLEAN="rm -f src/hp-wmi-omen/hp-wmi.ko src/hp-wmi-omen/*.o || true" +MAKE[0]="make -C $kernel_source_dir M=$dkms_tree/$module/$module_version/build/src EXTRA_CFLAGS='' modules" BUILT_MODULE_NAME[0]="hp-wmi" BUILT_MODULE_LOCATION[0]="src/hp-wmi-omen/" DEST_MODULE_LOCATION[0]="/kernel/drivers/platform/x86/hp" diff --git a/src/omen_fan_control/data/driver/src/Makefile b/src/omen_fan_control/data/driver/src/Makefile new file mode 100644 index 0000000..5086828 --- /dev/null +++ b/src/omen_fan_control/data/driver/src/Makefile @@ -0,0 +1 @@ +obj-m += hp-wmi-omen/hp-wmi.o From 124eb75a39a8298e993455d76afe1996bbb6567c Mon Sep 17 00:00:00 2001 From: Casu Al Snek Date: Sun, 22 Feb 2026 19:18:12 +0545 Subject: [PATCH 5/8] feat: Better way to handle systemd unit dropin --- arch/omen-fan-control/PKGBUILD | 9 ++++++++- .../data/omen-fan-control.service | 15 +++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 src/omen_fan_control/data/omen-fan-control.service diff --git a/arch/omen-fan-control/PKGBUILD b/arch/omen-fan-control/PKGBUILD index 1f7c2bd..12a7601 100644 --- a/arch/omen-fan-control/PKGBUILD +++ b/arch/omen-fan-control/PKGBUILD @@ -45,7 +45,14 @@ package() { [[ -f "$f" ]] && install -Dm644 "$f" "$pkgdir/usr/share/omen-fan-control/driver/hooks/$(basename "$f")" done - # systemd drop-in or profile.d so OMEN_FAN_CONTROL_DIR is set for all users + # systemd service (placeholder @EXECSTART@ replaced with installed executable path) + install -dm755 "$pkgdir/usr/lib/systemd/system" + sed 's|@EXECSTART@|/usr/bin/omen-fan-control serve|g' \ + "$srcdir/src/omen_fan_control/data/omen-fan-control.service" \ + > "$pkgdir/usr/lib/systemd/system/omen-fan-control.service" + chmod 644 "$pkgdir/usr/lib/systemd/system/omen-fan-control.service" + + # profile.d so OMEN_FAN_CONTROL_DIR is set for all users install -dm755 "$pkgdir/etc/profile.d" printf '%s\n' 'export OMEN_FAN_CONTROL_DIR=/usr/share/omen-fan-control' > "$pkgdir/etc/profile.d/omen-fan-control.sh" chmod 644 "$pkgdir/etc/profile.d/omen-fan-control.sh" diff --git a/src/omen_fan_control/data/omen-fan-control.service b/src/omen_fan_control/data/omen-fan-control.service new file mode 100644 index 0000000..ae99d35 --- /dev/null +++ b/src/omen_fan_control/data/omen-fan-control.service @@ -0,0 +1,15 @@ +[Unit] +Description=HP Omen Fan Control Service +After=multi-user.target + +[Service] +Type=simple +ExecStart=@EXECSTART@ +WorkingDirectory=/ +Restart=on-failure +StartLimitBurst=5 +RestartSec=5 +User=root + +[Install] +WantedBy=multi-user.target From a45a53e69f585a5542e5a6642b39e2685be027a7 Mon Sep 17 00:00:00 2001 From: Casu Al Snek Date: Sun, 22 Feb 2026 19:27:55 +0545 Subject: [PATCH 6/8] chore: Add back the link of GUI screenshot. --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5d30c4c..6d2bda9 100644 --- a/README.md +++ b/README.md @@ -125,9 +125,8 @@ sudo omen-fan-control-gui **GUI Fan Curve** - -| | -| --- | +|Omen Fan Control GUI| +|---| ### CLI From 1aaa24e4031126b41882a1d05709d204b625aa7e Mon Sep 17 00:00:00 2001 From: Casu Al Snek Date: Sun, 22 Feb 2026 22:57:55 +0545 Subject: [PATCH 7/8] feat: Add deb build. Package Build, Still needs testing --- deb/build-in-docker.sh | 36 +++++++++++++++ deb/build.sh | 53 +++++++++++++++++++++++ deb/hp-wmi-omen-dkms/debian/changelog | 5 +++ deb/hp-wmi-omen-dkms/debian/control | 16 +++++++ deb/hp-wmi-omen-dkms/debian/rules | 30 +++++++++++++ deb/hp-wmi-omen-dkms/debian/source/format | 1 + deb/omen-fan-control/debian/changelog | 5 +++ deb/omen-fan-control/debian/control | 24 ++++++++++ deb/omen-fan-control/debian/rules | 45 +++++++++++++++++++ deb/omen-fan-control/debian/source/format | 1 + 10 files changed, 216 insertions(+) create mode 100755 deb/build-in-docker.sh create mode 100755 deb/build.sh create mode 100644 deb/hp-wmi-omen-dkms/debian/changelog create mode 100644 deb/hp-wmi-omen-dkms/debian/control create mode 100755 deb/hp-wmi-omen-dkms/debian/rules create mode 100644 deb/hp-wmi-omen-dkms/debian/source/format create mode 100644 deb/omen-fan-control/debian/changelog create mode 100644 deb/omen-fan-control/debian/control create mode 100755 deb/omen-fan-control/debian/rules create mode 100644 deb/omen-fan-control/debian/source/format diff --git a/deb/build-in-docker.sh b/deb/build-in-docker.sh new file mode 100755 index 0000000..ec70d46 --- /dev/null +++ b/deb/build-in-docker.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# Build .deb packages inside a Debian container (for testing on non-Debian hosts). +# Requires: Docker (docker run). +# Usage: ./deb/build-in-docker.sh [hp-wmi-omen-dkms|omen-fan-control|all] +set -e + +REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +TARGET="${1:-all}" + +if ! command -v docker &>/dev/null; then + echo "Error: docker not found. Install docker to build .deb on this host." >&2 + exit 1 +fi + +# Use bookworm for a stable, recent Debian +IMAGE="${DEB_BUILD_IMAGE:-debian:bookworm}" + +echo "Pulling image $IMAGE (set DEB_BUILD_IMAGE to override) ..." +docker pull "$IMAGE" + +echo "Installing build deps and building .deb in container ..." +docker run --rm --network=host \ + -v "$REPO_ROOT:/src:rw" \ + -w /src \ + "$IMAGE" \ + bash -ex -c ' + apt-get update + apt-get install -y \ + debhelper dpkg-dev \ + dkms \ + python3 python3-pip python3-venv python3-build python3-installer python3-hatchling + ./deb/build.sh "'"$TARGET"'" + ' + +echo "Done. Built packages in deb/build/:" +ls -la "$REPO_ROOT/deb/build/"*.deb 2>/dev/null || true \ No newline at end of file diff --git a/deb/build.sh b/deb/build.sh new file mode 100755 index 0000000..9d6f1ce --- /dev/null +++ b/deb/build.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash +# Build .deb packages for Debian/Ubuntu from repo root. +# Usage: ./deb/build.sh [hp-wmi-omen-dkms|omen-fan-control|all] +set -e + +REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +DRIVER_SRC="$REPO_ROOT/src/omen_fan_control/data/driver" +BUILD_DIR="$REPO_ROOT/deb/build" + +build_hp_wmi_omen_dkms() { + echo "=== Building hp-wmi-omen-dkms ===" + rm -rf "$BUILD_DIR/hp-wmi-omen-dkms" + mkdir -p "$BUILD_DIR/hp-wmi-omen-dkms" + cp "$DRIVER_SRC/dkms.conf" "$BUILD_DIR/hp-wmi-omen-dkms/" + mkdir -p "$BUILD_DIR/hp-wmi-omen-dkms/src" + cp "$DRIVER_SRC/src/Makefile" "$BUILD_DIR/hp-wmi-omen-dkms/src/" + cp -r "$DRIVER_SRC/hp-wmi-omen" "$BUILD_DIR/hp-wmi-omen-dkms/src/" + cp -r "$REPO_ROOT/deb/hp-wmi-omen-dkms/debian" "$BUILD_DIR/hp-wmi-omen-dkms/" + (cd "$BUILD_DIR/hp-wmi-omen-dkms" && dpkg-buildpackage -b -uc -us) + echo "Built: $BUILD_DIR/hp-wmi-omen-dkms_1.0_*.deb" +} + +build_omen_fan_control() { + echo "=== Building omen-fan-control ===" + rm -rf "$BUILD_DIR/omen-fan-control" + mkdir -p "$BUILD_DIR/omen-fan-control" + cp "$REPO_ROOT/pyproject.toml" "$BUILD_DIR/omen-fan-control/" + cp -r "$REPO_ROOT/src" "$BUILD_DIR/omen-fan-control/" + for f in README.md LICENSE.md; do + [[ -f "$REPO_ROOT/$f" ]] && cp "$REPO_ROOT/$f" "$BUILD_DIR/omen-fan-control/" + done + cp -r "$REPO_ROOT/deb/omen-fan-control/debian" "$BUILD_DIR/omen-fan-control/" + (cd "$BUILD_DIR/omen-fan-control" && dpkg-buildpackage -b -uc -us) + echo "Built: $BUILD_DIR/omen-fan-control_1.0.0_*.deb" +} + +main() { + local target="${1:-all}" + case "$target" in + hp-wmi-omen-dkms) build_hp_wmi_omen_dkms ;; + omen-fan-control) build_omen_fan_control ;; + all) + build_hp_wmi_omen_dkms + build_omen_fan_control + ;; + *) + echo "Usage: $0 [hp-wmi-omen-dkms|omen-fan-control|all]" >&2 + exit 1 + ;; + esac +} + +main "$@" diff --git a/deb/hp-wmi-omen-dkms/debian/changelog b/deb/hp-wmi-omen-dkms/debian/changelog new file mode 100644 index 0000000..84a6691 --- /dev/null +++ b/deb/hp-wmi-omen-dkms/debian/changelog @@ -0,0 +1,5 @@ +hp-wmi-omen-dkms (1.0) unstable; urgency=medium + + * Patched hp-wmi DKMS module for HP Omen/Victus fan control. + + -- Arfelious Fri, 20 Feb 2026 12:00:00 +0000 diff --git a/deb/hp-wmi-omen-dkms/debian/control b/deb/hp-wmi-omen-dkms/debian/control new file mode 100644 index 0000000..6fe1a1d --- /dev/null +++ b/deb/hp-wmi-omen-dkms/debian/control @@ -0,0 +1,16 @@ +Source: hp-wmi-omen-dkms +Section: kernel +Priority: optional +Maintainer: Arfelious +Build-Depends: debhelper-compat (= 13), dkms +Standards-Version: 4.6.2 +Rules-Requires-Root: no +Homepage: https://github.com/arfelious/omen-fan-control + +Package: hp-wmi-omen-dkms +Architecture: all +Depends: ${misc:Depends}, dkms +Description: Patched hp-wmi driver for HP Omen/Victus fan control (DKMS) + This DKMS package builds a patched hp-wmi kernel module that exposes + fan control (pwm1) for HP Omen Max, Victus and Omen laptops on kernels + before 6.20. Linux 6.20+ includes equivalent support upstream. diff --git a/deb/hp-wmi-omen-dkms/debian/rules b/deb/hp-wmi-omen-dkms/debian/rules new file mode 100755 index 0000000..b11499f --- /dev/null +++ b/deb/hp-wmi-omen-dkms/debian/rules @@ -0,0 +1,30 @@ +#!/usr/bin/make -f +# HP Omen Fan Control - DKMS package build rules +# Driver source is prepared by deb/build.sh before calling dpkg-buildpackage. + +export DH_VERBOSE = 1 +export DEB_BUILD_MAINT_OPTIONS = hardening=+all + +PKG_DIR := debian/hp-wmi-omen-dkms +DKMS_REL := usr/src/hp-wmi-omen-1.0 + +%: + dh $@ + +override_dh_auto_install: + install -d "$(PKG_DIR)/$(DKMS_REL)" + install -m644 dkms.conf "$(PKG_DIR)/$(DKMS_REL)/dkms.conf" + sed -e 's/@PKGNAME@/hp-wmi-omen/g' -e 's/@PKGVER@/1.0/g' -i "$(PKG_DIR)/$(DKMS_REL)/dkms.conf" + install -d "$(PKG_DIR)/$(DKMS_REL)/src" + install -m644 src/Makefile "$(PKG_DIR)/$(DKMS_REL)/src/Makefile" + cp -r src/hp-wmi-omen "$(PKG_DIR)/$(DKMS_REL)/src/" + +override_dh_auto_build: + # Nothing to compile; driver is built by DKMS at install time + true + +override_dh_auto_configure: + true + +override_dh_auto_clean: + true diff --git a/deb/hp-wmi-omen-dkms/debian/source/format b/deb/hp-wmi-omen-dkms/debian/source/format new file mode 100644 index 0000000..89ae9db --- /dev/null +++ b/deb/hp-wmi-omen-dkms/debian/source/format @@ -0,0 +1 @@ +3.0 (native) diff --git a/deb/omen-fan-control/debian/changelog b/deb/omen-fan-control/debian/changelog new file mode 100644 index 0000000..018611c --- /dev/null +++ b/deb/omen-fan-control/debian/changelog @@ -0,0 +1,5 @@ +omen-fan-control (1.0.0) unstable; urgency=medium + + * Fan control CLI and GUI for HP Omen/Victus laptops on Linux. + + -- Arfelious Fri, 20 Feb 2026 12:00:00 +0000 diff --git a/deb/omen-fan-control/debian/control b/deb/omen-fan-control/debian/control new file mode 100644 index 0000000..6808e26 --- /dev/null +++ b/deb/omen-fan-control/debian/control @@ -0,0 +1,24 @@ +Source: omen-fan-control +Section: utils +Priority: optional +Maintainer: Arfelious +Build-Depends: debhelper-compat (= 13), + python3-build, + python3-installer, + python3-hatchling +Standards-Version: 4.6.2 +Rules-Requires-Root: no +Homepage: https://github.com/arfelious/omen-fan-control + +Package: omen-fan-control +Architecture: all +Depends: ${misc:Depends}, + python3, + python3-click, + python3-pyqt6 +Suggests: hp-wmi-omen-dkms +Description: Fan control for HP Omen Max, Victus and Omen laptops (CLI + GUI) + CLI and GUI to control fan speed on supported HP Omen and Victus laptops + on Linux. Install hp-wmi-omen-dkms for persistent patched driver across + kernel updates, or use "omen-fan-control install-patch permanent" from + this package. diff --git a/deb/omen-fan-control/debian/rules b/deb/omen-fan-control/debian/rules new file mode 100755 index 0000000..bb4741e --- /dev/null +++ b/deb/omen-fan-control/debian/rules @@ -0,0 +1,45 @@ +#!/usr/bin/make -f +# HP Omen Fan Control - Python application package +# Source tree (pyproject.toml, src/, README, etc.) is prepared by deb/build.sh. + +export DH_VERBOSE = 1 +export DEB_BUILD_MAINT_OPTIONS = hardening=+all + +%: + dh $@ + +override_dh_auto_build: + python3 -m build --wheel -o dist/ + +override_dh_auto_install: + # Install Python wheel (entry points + module) + install -d debian/omen-fan-control/usr + python3 -m installer --compile-bytecode=0 -d debian/omen-fan-control --prefix /usr dist/omen_fan_control*.whl + # If installer put scripts in usr/local/bin (ignores --prefix on some setups), move to usr/bin + if [ -d debian/omen-fan-control/usr/local/bin ]; then \ + install -d debian/omen-fan-control/usr/bin; \ + mv debian/omen-fan-control/usr/local/bin/* debian/omen-fan-control/usr/bin/; \ + rmdir debian/omen-fan-control/usr/local/bin 2>/dev/null || true; \ + rmdir debian/omen-fan-control/usr/local 2>/dev/null || true; \ + fi + # Driver data for "install-patch permanent" + install -d debian/omen-fan-control/usr/share/omen-fan-control/driver + install -m644 src/omen_fan_control/data/driver/dkms.conf debian/omen-fan-control/usr/share/omen-fan-control/driver/ + install -d debian/omen-fan-control/usr/share/omen-fan-control/driver/src + install -m644 src/omen_fan_control/data/driver/src/Makefile debian/omen-fan-control/usr/share/omen-fan-control/driver/src/ + cp -r src/omen_fan_control/data/driver/hp-wmi-omen debian/omen-fan-control/usr/share/omen-fan-control/driver/ + install -m755 src/omen_fan_control/data/driver/install_driver.sh debian/omen-fan-control/usr/share/omen-fan-control/driver/ + install -d debian/omen-fan-control/usr/share/omen-fan-control/driver/hooks + for f in src/omen_fan_control/data/driver/hooks/*; do [ -f "$$f" ] && install -m644 "$$f" debian/omen-fan-control/usr/share/omen-fan-control/driver/hooks/$$(basename "$$f"); done + # systemd service + install -d debian/omen-fan-control/usr/lib/systemd/system + sed 's|@EXECSTART@|/usr/bin/omen-fan-control serve|g' src/omen_fan_control/data/omen-fan-control.service > debian/omen-fan-control/usr/lib/systemd/system/omen-fan-control.service + chmod 644 debian/omen-fan-control/usr/lib/systemd/system/omen-fan-control.service + # profile.d + install -d debian/omen-fan-control/etc/profile.d + printf '%s\n' 'export OMEN_FAN_CONTROL_DIR=/usr/share/omen-fan-control' > debian/omen-fan-control/etc/profile.d/omen-fan-control.sh + chmod 644 debian/omen-fan-control/etc/profile.d/omen-fan-control.sh + +override_dh_usrlocal: + # Scripts are in usr/bin; nothing to relocate from usr/local + true diff --git a/deb/omen-fan-control/debian/source/format b/deb/omen-fan-control/debian/source/format new file mode 100644 index 0000000..89ae9db --- /dev/null +++ b/deb/omen-fan-control/debian/source/format @@ -0,0 +1 @@ +3.0 (native) From 9cf114016847a0a06eb31b4bf075ebb6ccbdcaa4 Mon Sep 17 00:00:00 2001 From: Casu Al Snek Date: Mon, 23 Feb 2026 00:35:32 +0545 Subject: [PATCH 8/8] fix: Add pre/post install hooks to update/remove DKMS modules --- .../debian/hp-wmi-omen-dkms.postinst | 15 +++++++++++++++ .../debian/hp-wmi-omen-dkms.prerm | 11 +++++++++++ 2 files changed, 26 insertions(+) create mode 100755 deb/hp-wmi-omen-dkms/debian/hp-wmi-omen-dkms.postinst create mode 100755 deb/hp-wmi-omen-dkms/debian/hp-wmi-omen-dkms.prerm diff --git a/deb/hp-wmi-omen-dkms/debian/hp-wmi-omen-dkms.postinst b/deb/hp-wmi-omen-dkms/debian/hp-wmi-omen-dkms.postinst new file mode 100755 index 0000000..ef78cbe --- /dev/null +++ b/deb/hp-wmi-omen-dkms/debian/hp-wmi-omen-dkms.postinst @@ -0,0 +1,15 @@ +#!/bin/sh +set -e + +case "$1" in + configure) + # Remove previous registration so we can re-add cleanly (e.g. after upgrade) + if command -v dkms >/dev/null 2>&1; then + dkms remove hp-wmi-omen/1.0 --all 2>/dev/null || true + dkms add hp-wmi-omen/1.0 + dkms autoinstall + fi + ;; +esac + +exit 0 diff --git a/deb/hp-wmi-omen-dkms/debian/hp-wmi-omen-dkms.prerm b/deb/hp-wmi-omen-dkms/debian/hp-wmi-omen-dkms.prerm new file mode 100755 index 0000000..6c41d2b --- /dev/null +++ b/deb/hp-wmi-omen-dkms/debian/hp-wmi-omen-dkms.prerm @@ -0,0 +1,11 @@ +#!/bin/sh +set -e + +# On remove or upgrade, unregister from DKMS so the module is not built for new kernels +if [ "$1" = "remove" ] || [ "$1" = "upgrade" ]; then + if command -v dkms >/dev/null 2>&1; then + dkms remove hp-wmi-omen/1.0 --all 2>/dev/null || true + fi +fi + +exit 0