mirror of
https://github.com/NixOS/nixos-hardware
synced 2024-12-29 04:59:45 +01:00
4161f8aee8
Co-authored-by: Jörg Thalheim <Mic92@users.noreply.github.com>
21 lines
597 B
Nix
21 lines
597 B
Nix
{ 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
|
|
|
|
{
|
|
options.hardware.asus.battery.chargeUpto = lib.mkOption {
|
|
description = "Maximum level of charge for your battery, as a percentage.";
|
|
default = 100;
|
|
type = lib.types.int;
|
|
};
|
|
config = {
|
|
environment.systemPackages = [ p ];
|
|
systemd.tmpfiles.rules = [
|
|
"w /sys/class/power_supply/BAT0/charge_control_end_threshold - - - - ${toString cfg.battery.chargeUpto}"
|
|
];
|
|
};
|
|
}
|