about summary refs log tree commit diff
path: root/users/aspen
diff options
context:
space:
mode:
Diffstat (limited to 'users/aspen')
-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}"''
-      ];
-    };
-}