Configure power actions with logind

This configures what happens on lid close (on battery / on AC) and
control what happens on the power button press.
This commit is contained in:
ItsDrike 2024-06-25 01:38:05 +02:00
parent 6bbebb3cd2
commit b930b14cf2
Signed by: ItsDrike
GPG key ID: FA2745890B7048C0
2 changed files with 19 additions and 0 deletions

View file

@ -4,6 +4,7 @@
./mount.nix
./printing.nix
./misc.nix
./logind.nix
./gnome-keyring.nix
];
}

View file

@ -0,0 +1,18 @@
{lib, config, ...}: let
inherit (lib) mkIf;
deviceType = config.myOptions.device.roles.type;
acceptedTypes = ["laptop" "desktop"];
in {
config = mkIf (builtins.elem deviceType acceptedTypes) {
# despite being under logind, this has nothing to do with login
# it's about power management
services.logind = {
lidSwitch = "suspend-then-hibernate";
lidSwitchExternalPower = "lock";
extraConfig = ''
HandlePowerKey=suspend-then-hibernate
HibernateDelaySec=3600
'';
};
};
}