2021-11-18 23:01:56 +00:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
let
|
|
|
|
p = pkgs.writeScriptBin "charge-upto" ''
|
|
|
|
echo ''${0:-100} > /sys/class/power_supply/BAT0/charge_control_end_threshold
|
|
|
|
'';
|
|
|
|
cfg = config.hardware.asus;
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
2021-11-20 22:26:52 +00:00
|
|
|
options.hardware.asus.battery.chargeUpto = lib.mkOption {
|
2021-11-18 23:01:56 +00:00
|
|
|
description = "Maximum level of charge for your battery, as a percentage.";
|
|
|
|
default = 100;
|
|
|
|
type = lib.types.int;
|
|
|
|
};
|
|
|
|
config = {
|
|
|
|
environment.systemPackages = [ p ];
|
|
|
|
systemd.tmpfiles.rules = [
|
2021-11-20 22:26:52 +00:00
|
|
|
"w /sys/class/power_supply/BAT0/charge_control_end_threshold - - - - ${toString cfg.battery.chargeUpto}"
|
2021-11-18 23:01:56 +00:00
|
|
|
];
|
|
|
|
};
|
|
|
|
}
|