From fea6c6e9fe06e1ff1869c26c6e217d1673cb7b5b Mon Sep 17 00:00:00 2001 From: Dmitry Voronin Date: Wed, 24 Jan 2024 21:09:19 +0300 Subject: [PATCH] Powerlimit : Add laptop battery limiter. --- .config/linux/nix/Powerlimit.nix | 15 +++++++++++++++ .config/linux/nix/PowersaveAmd.nix | 2 +- .config/linux/nix/PowersaveIntel.nix | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 .config/linux/nix/Powerlimit.nix diff --git a/.config/linux/nix/Powerlimit.nix b/.config/linux/nix/Powerlimit.nix new file mode 100644 index 0000000..29c6fd1 --- /dev/null +++ b/.config/linux/nix/Powerlimit.nix @@ -0,0 +1,15 @@ +{ pkgs, ... }: + +{ + systemd.services.powerlimit = { + enable = true; + description = "Limit battery charge."; + serviceConfig = { + Type = "simple"; + RemainAfterExit = "yes"; + ExecStart = "${pkgs.bash}/bin/bash -c 'echo 40 > /sys/class/power_supply/BAT0/charge_control_start_threshold; echo 80 > /sys/class/power_supply/BAT0/charge_control_end_threshold;'"; + ExecStop = "${pkgs.bash}/bin/bash -c 'echo 95 > /sys/class/power_supply/BAT0/charge_control_end_threshold; echo 90 > /sys/class/power_supply/BAT0/charge_control_start_threshold;'"; + }; + wantedBy = [ "multi-user.target" ]; + }; +} diff --git a/.config/linux/nix/PowersaveAmd.nix b/.config/linux/nix/PowersaveAmd.nix index 31fb01a..2cfcf07 100644 --- a/.config/linux/nix/PowersaveAmd.nix +++ b/.config/linux/nix/PowersaveAmd.nix @@ -3,7 +3,7 @@ { systemd.services.powersave = { enable = true; - description = "AMD Disable Boost"; + description = "AMD disable Boost"; serviceConfig = { Type = "simple"; RemainAfterExit = "yes"; diff --git a/.config/linux/nix/PowersaveIntel.nix b/.config/linux/nix/PowersaveIntel.nix index 5c90ff2..6c62065 100644 --- a/.config/linux/nix/PowersaveIntel.nix +++ b/.config/linux/nix/PowersaveIntel.nix @@ -3,7 +3,7 @@ { systemd.services.powersave = { enable = true; - description = "Intel Disable Boost"; + description = "Intel disable Boost"; serviceConfig = { Type = "simple"; RemainAfterExit = "yes";