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:
@@ -215,6 +215,7 @@ in {
|
|||||||
./newsboat.nix
|
./newsboat.nix
|
||||||
./flameshot-once.nix
|
./flameshot-once.nix
|
||||||
./packages
|
./packages
|
||||||
|
./power-action.nix
|
||||||
./printing.nix
|
./printing.nix
|
||||||
./wallpaper.nix
|
./wallpaper.nix
|
||||||
./redshift.nix
|
./redshift.nix
|
||||||
|
|||||||
24
configs/power-action.nix
Normal file
24
configs/power-action.nix
Normal 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}
|
||||||
|
'';
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user