From 28e7c642624966105537aa3c27714e95f79db02a Mon Sep 17 00:00:00 2001 From: Doloro1978 Date: Sat, 3 Jan 2026 13:55:11 +0000 Subject: [PATCH] laptop(battery): more optimizations --- hosts/doloro-laptop/laptop.nix | 41 ++++++++++++++++------------------ 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/hosts/doloro-laptop/laptop.nix b/hosts/doloro-laptop/laptop.nix index d21d731..5e625e5 100644 --- a/hosts/doloro-laptop/laptop.nix +++ b/hosts/doloro-laptop/laptop.nix @@ -16,12 +16,14 @@ in CPU_BOOST_ON_AC = 1; CPU_BOOST_ON_BAT = 0; CPU_BOOST_ON_SAV = 0; + DEVICES_TO_DISABLE_ON_BAT_NOT_IN_USE = "bluetooth wifi wwan"; + TLP_DEFAULT_BATTERY_MODE = "SAV"; CPU_HWP_DYN_BOOST_ON_AC = 1; CPU_HWP_DYN_BOOST_ON_BAT = 0; CPU_HWP_DYN_BOOST_ON_SAV = 0; PLATFORM_PROFILE_ON_AC = "balanced"; - PLATFORM_PROFILE_ON_BAT = "quiet"; + PLATFORM_PROFILE_ON_BAT = "low-power"; PLATFORM_PROFILE_ON_SAV = "quiet"; START_CHARGE_THRESH_BAT0 = 40; # 40 and below it starts to charge STOP_CHARGE_THRESH_BAT0 = 80; # 80 and above it stops charging @@ -48,30 +50,25 @@ in SuspendEstimationSec=120 ''; + systemd.services.rfkill-sleep-wake = { + enable = true; + description = "Using rfkill; disable all rf devices before sleeping."; + before = [ "sleep.target" ]; + + serviceConfig = { + + Type = "oneshot"; + ExecStop = ''${pkgs.utillinux}/bin/rfkill unblock all''; + ExecStart = ''${pkgs.utillinux}/bin/rfkill block all''; + RemainAfterExit = true; + }; + wantedBy = [ "sleep.target" ]; + partOf = [ "sleep.target" ]; + + }; # one of "ignore", "poweroff", "reboot", "halt", "kexec", "suspend", "hibernate", "hybrid-sleep", "suspend-then-hibernate", "lock" powerManagement = { enable = true; # powertop.enable = true; }; - systemd.user.services.rfkill-sleep = { - # I haven't tested this, but in theory, disabling rf devices before sleep will save on power - enable = true; - before = [ "systemd-suspend.service" ]; - wantedBy = [ "default.target" ]; - description = "Using rfkill; disables all rf devices before sleeping. useful for saving power"; - serviceConfig = { - Type = "simple"; - ExecStart = ''${pkgs.utillinux}/bin/rfkill block all''; - }; - }; - systemd.user.services.rfkill-wake = { - enable = true; - after = [ "systemd-suspend.service" ]; - wantedBy = [ "default.target" ]; - description = "Using rfkill; enable all rf devices after sleeping."; - serviceConfig = { - Type = "simple"; - ExecStart = ''${pkgs.utillinux}/bin/rfkill unblock all''; - }; - }; }