1
0
mirror of https://github.com/kmein/niveum synced 2026-03-16 10:11:08 +01:00

feat: power-action to suspend on low battery

This commit is contained in:
2021-01-26 22:59:57 +01:00
parent e553f1bcda
commit 63ad607d46
2 changed files with 25 additions and 0 deletions

View File

@@ -215,6 +215,7 @@ in {
./newsboat.nix
./flameshot-once.nix
./packages
./power-action.nix
./printing.nix
./wallpaper.nix
./redshift.nix

24
configs/power-action.nix Normal file
View File

@@ -0,0 +1,24 @@
{ pkgs, config, ... }:
let
suspend = pkgs.writers.writeDash "suspend" "${pkgs.systemd}/bin/systemctl suspend";
in
{
imports = [ <stockholm/krebs/3modules/power-action.nix> ];
krebs.power-action = {
enable = true;
plans.suspend = {
upperLimit = 3;
lowerLimit = 0;
charging = false;
action = pkgs.writeDash "suspend-wrapper" ''
/run/wrappers/bin/sudo ${suspend}
'';
};
user = config.users.users.me.name;
};
security.sudo.extraConfig = ''
${config.krebs.power-action.user} ALL= (root) NOPASSWD: ${suspend}
'';
}