mirror of
https://github.com/ItsDrike/nixdots
synced 2025-06-30 23:20:42 +00:00
Rework laptop battery/power optimization settings
This commit is contained in:
parent
dd00ed5f70
commit
a0bba2e225
4 changed files with 133 additions and 37 deletions
|
@ -0,0 +1,40 @@
|
|||
# This sets up power management using auto-cpufreq,
|
||||
# alongside with upower and power-profiles-daemon.
|
||||
# Together, this provides a complete alternative to TLP
|
||||
{ pkgs, lib, config, ...}: let
|
||||
inherit (lib) mkIf;
|
||||
inherit (lib.modules) mkForce;
|
||||
inherit (lib.strings) makeBinPath;
|
||||
deviceType = config.myOptions.device.roles.type;
|
||||
acceptedTypes = ["laptop"];
|
||||
in {
|
||||
config = mkIf (builtins.elem deviceType acceptedTypes) {
|
||||
# allows changing system behavior based upon user-selected power profiles
|
||||
# (with `powerprofilesctl` command)
|
||||
services.power-profiles-daemon.enable = true;
|
||||
|
||||
# Power state monitor. Switches power profiles based on charging state.
|
||||
# Plugged in - performance (if available, falls back to balance)
|
||||
# Unplugged - balanced, until below 50%, then power-saver
|
||||
systemd.services."power-monitor" = let
|
||||
dependencies = with pkgs; [
|
||||
coreutils
|
||||
power-profiles-daemon
|
||||
inotify-tools
|
||||
jaq
|
||||
];
|
||||
in {
|
||||
description = "Power Monitoring Service";
|
||||
environment.PATH = mkForce "/run/wrappers/bin:${makeBinPath dependencies}";
|
||||
script = builtins.readFile ./scripts/power_monitor.sh;
|
||||
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
Restart = "on-failure";
|
||||
};
|
||||
|
||||
wants = ["power-profiles-daemon.service"];
|
||||
wantedBy = ["default.target"];
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue