feat(gs/system): Add config for laptop battery
hibernate on low battery, and when the power button is pressed Change-Id: I6560fc770ee5707e59fb2763614de2b8000e156e Reviewed-on: https://cl.tvl.fyi/c/depot/+/2550 Reviewed-by: glittershark <grfn@gws.fyi> Tested-by: BuildkiteCI
This commit is contained in:
parent
06263bfde2
commit
949e55fde9
4 changed files with 17 additions and 4 deletions
|
@ -3,7 +3,7 @@
|
|||
{
|
||||
imports = [
|
||||
../modules/common.nix
|
||||
../modules/reusable/battery.nix
|
||||
../modules/laptop.nix
|
||||
../modules/tvl.nix
|
||||
../modules/fcitx.nix
|
||||
../modules/rtlsdr.nix
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
imports = [
|
||||
(modulesPath + "/installer/scan/not-detected.nix")
|
||||
../modules/common.nix
|
||||
../modules/reusable/battery.nix
|
||||
../modules/laptop.nix
|
||||
../modules/xserver.nix
|
||||
../modules/fonts.nix
|
||||
../modules/sound.nix
|
||||
|
|
13
users/glittershark/system/system/modules/laptop.nix
Normal file
13
users/glittershark/system/system/modules/laptop.nix
Normal file
|
@ -0,0 +1,13 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
{
|
||||
imports = [
|
||||
./reusable/battery.nix
|
||||
];
|
||||
|
||||
laptop.onLowBattery.enable = true;
|
||||
|
||||
services.logind.extraConfig = ''
|
||||
HandlePowerKey=hibernate
|
||||
'';
|
||||
}
|
|
@ -7,7 +7,7 @@ with lib;
|
|||
|
||||
thresholdPercentage = mkOption {
|
||||
description = "Threshold battery percentage on which to perform the action";
|
||||
default = 5;
|
||||
default = 8;
|
||||
type = types.int;
|
||||
};
|
||||
|
||||
|
@ -26,7 +26,7 @@ with lib;
|
|||
''SUBSYSTEM=="power_supply", ''
|
||||
''ATTR{status}=="Discharging", ''
|
||||
''ATTR{capacity}=="[0-${toString cfg.thresholdPercentage}]", ''
|
||||
''RUN+="/${pkgs.systemd}/bin/systemctl ${cfg.action}"''
|
||||
''RUN+="${pkgs.systemd}/bin/systemctl ${cfg.action}"''
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue