Rename my //users directory and all places that refer to glittershark to grfn, including nix references and documentation. This may require some extra attention inside of gerrit's database after it lands to allow me to actually push things. Change-Id: I4728b7ec2c60024392c1c1fa6e0d4a59b3e266fa Reviewed-on: https://cl.tvl.fyi/c/depot/+/2933 Tested-by: BuildkiteCI Reviewed-by: tazjin <mail@tazj.in> Reviewed-by: lukegb <lukegb@tvl.fyi> Reviewed-by: glittershark <grfn@gws.fyi>
32 lines
890 B
Nix
32 lines
890 B
Nix
{ 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}"''
|
|
];
|
|
};
|
|
}
|