diff options
author | sinanmohd <sinan@sinanmohd.com> | 2024-08-30 17:57:55 +0530 |
---|---|---|
committer | sinanmohd <sinan@sinanmohd.com> | 2024-08-30 17:57:55 +0530 |
commit | 70829a0af6e4eb428acfe112fe51a09da3ec3291 (patch) | |
tree | 44e5fd05c16eea3be2f8dd351acbaea927800bbb /os/common | |
parent | c75ab728a38ede1540a83aad307fefdb23fbabba (diff) |
common: hibernate on critical battery level
Diffstat (limited to 'os/common')
-rw-r--r-- | os/common/configuration.nix | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/os/common/configuration.nix b/os/common/configuration.nix index 047b153..8026b9f 100644 --- a/os/common/configuration.nix +++ b/os/common/configuration.nix @@ -1,4 +1,4 @@ -{ config, lib, ... }: let +{ config, pkgs, lib, ... }: let host = config.networking.hostName; in { disabledModules = [ @@ -23,6 +23,12 @@ in { size = 2048; # 2GB }]; + services.udev.extraRules = let + cmd = "${pkgs.systemd}/bin/systemctl hibernate"; + in '' + SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", ATTR{capacity}=="[0-5]", RUN+="${cmd}" + ''; + sops = { defaultSopsFile = ../${host}/secrets.yaml; age.keyFile = "/var/secrets/${host}.sops"; |