diff options
author | Griffin Smith <grfn@gws.fyi> | 2021-02-24T17·38-0500 |
---|---|---|
committer | glittershark <grfn@gws.fyi> | 2021-02-24T17·46+0000 |
commit | 949e55fde99398cc234196f9e69a3239c6c306a6 (patch) | |
tree | b43905ab72cf2a1e5efb7ea95e412f06f13ddb0a /users/glittershark/system/system/modules | |
parent | 06263bfde251a13b53b4cb7665b8b7c059701858 (diff) |
feat(gs/system): Add config for laptop battery r/2232
hibernate on low battery, and when the power button is pressed Change-Id: I6560fc770ee5707e59fb2763614de2b8000e156e Reviewed-on: https://cl.tvl.fyi/c/depot/+/2550 Reviewed-by: glittershark <grfn@gws.fyi> Tested-by: BuildkiteCI
Diffstat (limited to 'users/glittershark/system/system/modules')
-rw-r--r-- | users/glittershark/system/system/modules/laptop.nix | 13 | ||||
-rw-r--r-- | users/glittershark/system/system/modules/reusable/battery.nix | 4 |
2 files changed, 15 insertions, 2 deletions
diff --git a/users/glittershark/system/system/modules/laptop.nix b/users/glittershark/system/system/modules/laptop.nix new file mode 100644 index 0000000000..8c09f3a442 --- /dev/null +++ b/users/glittershark/system/system/modules/laptop.nix @@ -0,0 +1,13 @@ +{ config, lib, pkgs, ... }: + +{ + imports = [ + ./reusable/battery.nix + ]; + + laptop.onLowBattery.enable = true; + + services.logind.extraConfig = '' + HandlePowerKey=hibernate + ''; +} diff --git a/users/glittershark/system/system/modules/reusable/battery.nix b/users/glittershark/system/system/modules/reusable/battery.nix index d7043bf549..ca92e0c3f6 100644 --- a/users/glittershark/system/system/modules/reusable/battery.nix +++ b/users/glittershark/system/system/modules/reusable/battery.nix @@ -7,7 +7,7 @@ with lib; thresholdPercentage = mkOption { description = "Threshold battery percentage on which to perform the action"; - default = 5; + default = 8; type = types.int; }; @@ -26,7 +26,7 @@ with lib; ''SUBSYSTEM=="power_supply", '' ''ATTR{status}=="Discharging", '' ''ATTR{capacity}=="[0-${toString cfg.thresholdPercentage}]", '' - ''RUN+="/${pkgs.systemd}/bin/systemctl ${cfg.action}"'' + ''RUN+="${pkgs.systemd}/bin/systemctl ${cfg.action}"'' ]; }; } |