power-profiles-daemon: add profile switch udev rules on battery
Signed-off-by: Myned <dev@bjork.tech>
This commit is contained in:
parent
9839699d2d
commit
dfd22068bd
1 changed files with 21 additions and 2 deletions
|
@ -1,12 +1,18 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
powerprofilesctl = "${pkgs.power-profiles-daemon}/bin/powerprofilesctl";
|
||||
|
||||
cfg = config.custom.services.power-profiles-daemon;
|
||||
in {
|
||||
options.custom.services.power-profiles-daemon.enable = mkOption {default = false;};
|
||||
options.custom.services.power-profiles-daemon = {
|
||||
enable = mkOption {default = false;};
|
||||
auto = mkOption {default = true;};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
# https://gitlab.freedesktop.org/upower/power-profiles-daemon
|
||||
|
@ -14,7 +20,20 @@ in {
|
|||
#?? powerprofilesctl set <performance|balanced|power-saver>
|
||||
services = {
|
||||
power-profiles-daemon.enable = true;
|
||||
tlp.enable = false; # Conflicts with PPD
|
||||
|
||||
#!! Conflicts with power-profiles-daemon
|
||||
auto-cpufreq.enable = false;
|
||||
tlp.enable = false;
|
||||
|
||||
# Switch to power-saver mode when on battery
|
||||
# https://wiki.archlinux.org/title/Power_management#Using_a_script_and_an_udev_rule
|
||||
udev.extraRules = mkIf cfg.auto ''
|
||||
# Battery
|
||||
SUBSYSTEM=="power_supply", ATTR{online}=="0", RUN+="${powerprofilesctl} set power-saver"
|
||||
|
||||
# AC
|
||||
SUBSYSTEM=="power_supply", ATTR{online}=="1", RUN+="${powerprofilesctl} set balanced"
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue