From b930b14cf22b074e4fdd1f1f8175137a661af139 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Tue, 25 Jun 2024 01:38:05 +0200 Subject: [PATCH] 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. --- system/roles/workstation/services/default.nix | 1 + system/roles/workstation/services/logind.nix | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 system/roles/workstation/services/logind.nix diff --git a/system/roles/workstation/services/default.nix b/system/roles/workstation/services/default.nix index dcd7aee..ec9cd53 100644 --- a/system/roles/workstation/services/default.nix +++ b/system/roles/workstation/services/default.nix @@ -4,6 +4,7 @@ ./mount.nix ./printing.nix ./misc.nix + ./logind.nix ./gnome-keyring.nix ]; } diff --git a/system/roles/workstation/services/logind.nix b/system/roles/workstation/services/logind.nix new file mode 100644 index 0000000..86f778b --- /dev/null +++ b/system/roles/workstation/services/logind.nix @@ -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 + ''; + }; + }; +}