diff options
author | sternenseemann <sternenseemann@systemli.org> | 2022-03-02 22:02:30 +0100 |
---|---|---|
committer | sternenseemann <sternenseemann@systemli.org> | 2022-03-02 22:07:13 +0100 |
commit | da978ff35ac851daf060d36b82920f09f5fcccfe (patch) | |
tree | ac57149549e80196df623c1fdf9fe50451a86f33 /modules | |
parent | a6a2ba7139adf1a5661c21d79217f19d8e620f62 (diff) |
machines/sternenseemann: use upower over low-battery
I had some weird issues with the low-battery udev rule, mainly it not triggering when it should. Usually, the event would only get processed when the battery changed state, e.g. from Discharging to Charging. Consequently, the laptop would hibernate when you'd save it from running out of battery by plugging it in, but, if you forgot, it'd be content to run out of battery. I'll try upower instead now which is the “normal” solution used by the major desktop environments. It's has some extra complexity, as it also provides a d-bus API for other applications to use, but we'll see how it goes.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/hardware/low-battery.nix | 45 | ||||
-rw-r--r-- | modules/module-list.nix | 1 |
2 files changed, 0 insertions, 46 deletions
diff --git a/modules/hardware/low-battery.nix b/modules/hardware/low-battery.nix deleted file mode 100644 index 40c21178..00000000 --- a/modules/hardware/low-battery.nix +++ /dev/null @@ -1,45 +0,0 @@ -# based on https://code.tvl.fyi/tree/users/glittershark/system/system/modules/reusable/battery.nix -{ config, lib, pkgs, ... }: - -let - - inherit (pkgs.vuizvui.profpatsch) - getBins - ; - - cfg = config.vuizvui.hardware.low-battery; - - bins = getBins pkgs.systemd [ "systemctl" ]; - -in { - options = { - vuizvui.hardware.low-battery = { - enable = lib.mkEnableOption "suspend on low battery"; - - treshold = lib.mkOption { - description = "Percentage treshold on which to suspend"; - type = lib.types.int; - default = 5; - }; - - action = lib.mkOption { - description = "Type of suspend action to perform when treshold is reached"; - type = lib.types.enum [ - "hibernate" - "suspend" - "suspend-then-hibernate" - ]; - default = "suspend"; - }; - }; - }; - - config = lib.mkIf cfg.enable { - services.udev.extraRules = lib.concatStrings [ - ''SUBSYSTEM=="power_supply", '' - ''ATTR{status}=="Discharging", '' - ''ATTR{capacity}=="[0-${toString cfg.treshold}]", '' - ''RUN+="${bins.systemctl} ${cfg.action}"'' - ]; - }; -} diff --git a/modules/module-list.nix b/modules/module-list.nix index 3c1d5adc..7429c887 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -4,7 +4,6 @@ ./core/tests.nix ./core/lazy-packages.nix ./hardware/gamecontroller.nix - ./hardware/low-battery.nix ./hardware/rtl8192cu ./hardware/t100ha ./hardware/thinkpad.nix |