From 9aa5390da71e1fcb8967e972b4da78a920fa424a Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Mon, 1 Jul 2024 00:35:17 -0400 Subject: [PATCH] hardware/laptop: revert to power-profiles-daemon by default --- hardwareModules/laptop/default.nix | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/hardwareModules/laptop/default.nix b/hardwareModules/laptop/default.nix index fbcaf37f..9b11b7f1 100644 --- a/hardwareModules/laptop/default.nix +++ b/hardwareModules/laptop/default.nix @@ -3,11 +3,29 @@ lib, pkgs, ... -}: { +}: let + pp-adjuster = pkgs.writeShellScriptBin "pp-adjuster" '' + current_profile=$(${lib.getExe' pkgs.power-profiles-daemon "powerprofilesctl"} get | tr -d '[:space:]') + if [ "$current_profile" == "power-saver" ]; then + ${lib.getExe' pkgs.power-profiles-daemon "powerprofilesctl"} set balanced + elif [ "$current_profile" == "balanced" ]; then + ${lib.getExe' pkgs.power-profiles-daemon "powerprofilesctl"} set performance + elif [ "$current_profile" == "performance" ]; then + ${lib.getExe' pkgs.power-profiles-daemon "powerprofilesctl"} set power-saver + fi + new_profile=$(${lib.getExe' pkgs.power-profiles-daemon "powerprofilesctl"} get | tr -d '[:space:]') + ${lib.getExe pkgs.libnotify} "Power profile set to $new_profile." + ''; +in { config = lib.mkIf config.ar.hardware.laptop { + environment.systemPackages = + lib.optional (config.services.power-profiles-daemon.enable) + pp-adjuster; + services = { - power-profiles-daemon.enable = lib.mkDefault false; + power-profiles-daemon.enable = true; upower.enable = true; + tlp = { enable = !config.services.power-profiles-daemon.enable; settings = {