chore(aspen/system): Drop custom battery service in favor of upower
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>
This commit is contained in:
parent
1dd378b0b8
commit
d959358e1f
2 changed files with 14 additions and 39 deletions
|
@ -1,15 +1,22 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
imports = [
|
services.logind = {
|
||||||
./reusable/battery.nix
|
powerKey = "hibernate";
|
||||||
];
|
powerKeyLongPress = "poweroff";
|
||||||
|
lidSwitch = "hybrid-sleep";
|
||||||
|
lidSwitchExternalPower = "ignore";
|
||||||
|
};
|
||||||
|
|
||||||
laptop.onLowBattery.enable = true;
|
systemd.sleep.extraConfig = ''
|
||||||
|
HibernateDelaySec=30m
|
||||||
services.logind.extraConfig = ''
|
SuspendState=mem
|
||||||
HandlePowerKey=hibernate
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
services.tlp.enable = true;
|
services.tlp.enable = true;
|
||||||
|
|
||||||
|
services.upower = {
|
||||||
|
enable = true;
|
||||||
|
criticalPowerAction = "Hibernate";
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -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}"''
|
|
||||||
];
|
|
||||||
};
|
|
||||||
}
|
|
Loading…
Reference in a new issue