about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAspen Smith <root@gws.fyi>2024-03-31T18·16-0400
committerclbot <clbot@tvl.fyi>2024-03-31T18·34+0000
commitd959358e1fc3d91519ee75cc702eacef2af2f935 (patch)
treefc99389a8d6c176db41d43b3c242d5b0a5780f17
parent1dd378b0b8f30b5701051b33512608d5b8ea6059 (diff)
chore(aspen/system): Drop custom battery service in favor of upower r/7815
Change-Id: Ie3e5aeba7026724dacbe4d0dc15a1112a22c3670
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11304
Autosubmit: aspen <root@gws.fyi>
Tested-by: BuildkiteCI
Reviewed-by: aspen <root@gws.fyi>
-rw-r--r--users/aspen/system/system/modules/laptop.nix21
-rw-r--r--users/aspen/system/system/modules/reusable/battery.nix32
2 files changed, 14 insertions, 39 deletions
diff --git a/users/aspen/system/system/modules/laptop.nix b/users/aspen/system/system/modules/laptop.nix
index 05c5333e513f..489b6cbc0459 100644
--- a/users/aspen/system/system/modules/laptop.nix
+++ b/users/aspen/system/system/modules/laptop.nix
@@ -1,15 +1,22 @@
 { config, lib, pkgs, ... }:
 
 {
-  imports = [
-    ./reusable/battery.nix
-  ];
+  services.logind = {
+    powerKey = "hibernate";
+    powerKeyLongPress = "poweroff";
+    lidSwitch = "hybrid-sleep";
+    lidSwitchExternalPower = "ignore";
+  };
 
-  laptop.onLowBattery.enable = true;
-
-  services.logind.extraConfig = ''
-    HandlePowerKey=hibernate
+  systemd.sleep.extraConfig = ''
+    HibernateDelaySec=30m
+    SuspendState=mem
   '';
 
   services.tlp.enable = true;
+
+  services.upower = {
+    enable = true;
+    criticalPowerAction = "Hibernate";
+  };
 }
diff --git a/users/aspen/system/system/modules/reusable/battery.nix b/users/aspen/system/system/modules/reusable/battery.nix
deleted file mode 100644
index 151c2a246f32..000000000000
--- a/users/aspen/system/system/modules/reusable/battery.nix
+++ /dev/null
@@ -1,32 +0,0 @@
-{ config, lib, pkgs, ... }:
-with lib;
-{
-  options = {
-    laptop.onLowBattery = {
-      enable = mkEnableOption "Perform action on low battery";
-
-      thresholdPercentage = mkOption {
-        description = "Threshold battery percentage on which to perform the action";
-        default = 8;
-        type = types.int;
-      };
-
-      action = mkOption {
-        description = "Action to perform on low battery";
-        default = "hibernate";
-        type = types.enum [ "hibernate" "suspend" "suspend-then-hibernate" ];
-      };
-    };
-  };
-
-  config =
-    let cfg = config.laptop.onLowBattery;
-    in mkIf cfg.enable {
-      services.udev.extraRules = concatStrings [
-        ''SUBSYSTEM=="power_supply", ''
-        ''ATTR{status}=="Discharging", ''
-        ''ATTR{capacity}=="[0-${toString cfg.thresholdPercentage}]", ''
-        ''RUN+="${pkgs.systemd}/bin/systemctl ${cfg.action}"''
-      ];
-    };
-}