{ pkgs, config, lib, ... }: let inherit (lib) mkOption types; in { options.batMode = mkOption { type = types.enum [ "single" "double" ]; default = "single"; description = "Select 'single' for one battery and 'double' for dual setup"; }; # Dont run a tandem with tlp #options.services.auto-cpufreq.enable = true; #options.services.auto-cpufreq.settings = { # battery = { # governor = "powersave"; # turbo = "never"; # }; # charger = { # governor = "performance"; # turbo = "auto"; # }; #}; config = { powerManagement.powertop.enable = true; services.upower = { enable = true; # In accordance with the waybar battery colors percentageLow = 30; percentageCritical = 20; percentageAction = 10; #percentageAction = "PowerOff"; criticalPowerAction = "PowerOff"; # This can destroy work usePercentageForPolicy = true; }; services.tlp = if config.batMode == "single" then { enable = true; settings = { #Optional helps save long term battery health # Going almost full because the other bat is also charged # 0 NEW first START_CHARGE_THRESH_BAT0 = 65; STOP_CHARGE_THRESH_BAT0 = 85; CPU_SCALING_GOVERNOR_ON_AC = "performance"; #CPU_SCALING_GOVERNOR_ON_BAT = "powersave"; #CPU_ENERGY_PERF_POLICY_ON_BAT = "power"; CPU_ENERGY_PERF_POLICY_ON_AC = "performance"; CPU_MIN_PERF_ON_AC = 0; CPU_MAX_PERF_ON_AC = 100; CPU_MIN_PERF_ON_BAT = 0; CPU_MAX_PERF_ON_BAT = 65; }; } else { enable = true; settings = { # Have to keep it this way or # Otherwise the buil in stop at 5% stops worky # The problem is here that only the second battery gets seen from the charging cap # Workaround. Just charge the battery when you use it and then turn manually the battery off # I mean it is the state you generate now that you can use on any laptop. so CPU_SCALING_GOVERNOR_ON_AC = "performance"; CPU_SCALING_GOVERNOR_ON_BAT = "powersave"; CPU_ENERGY_PERF_POLICY_ON_BAT = "power"; CPU_ENERGY_PERF_POLICY_ON_AC = "performance"; CPU_MIN_PERF_ON_AC = 0; CPU_MAX_PERF_ON_AC = 100; CPU_MIN_PERF_ON_BAT = 0; CPU_MAX_PERF_ON_BAT = 75; # 0 NEW first START_CHARGE_THRESH_BAT0 = 60; STOP_CHARGE_THRESH_BAT0 = 85; # 1 OLD second START_CHARGE_THRESH_BAT1 = 60; STOP_CHARGE_THRESH_BAT1 = 85; }; }; }; }