From 8ef9c2914a5112fec6453731746c01532fc093f4 Mon Sep 17 00:00:00 2001 From: Antoine Viallon Date: Mon, 27 Feb 2023 19:46:41 +0100 Subject: [PATCH] [Power] Reduce wrong (battery|ac)-power targets starts issues --- power.nix | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/power.nix b/power.nix index 6744198..d547cbc 100644 --- a/power.nix +++ b/power.nix @@ -96,7 +96,6 @@ in { config = mkIf cfg.enable { systemd.targets.ac-power = { description = "Target is active when AC is plugged-in."; - wantedBy = [ "multi-user.target" ]; conflicts = [ "battery-power.target" ]; unitConfig = { ConditionACPower = true; @@ -105,16 +104,18 @@ in { systemd.targets.battery-power = { description = "Target is active when power is drawn from a battery."; - wantedBy = [ "multi-user.target" ]; conflicts = [ "ac-power.target" ]; + unitConfig = { + ConditionACPower = false; + }; }; services.udev.extraRules = '' - KERNEL=="AC*", SUBSYSTEM=="power_supply", ATTR{online}=="0", RUN+="${pkgs.systemd}/bin/systemctl stop ac-power.target" - KERNEL=="AC*", SUBSYSTEM=="power_supply", ATTR{online}=="1", RUN+="${pkgs.systemd}/bin/systemctl start ac-power.target" + ACTION!="remove", KERNEL=="AC*", SUBSYSTEM=="power_supply", ATTR{online}=="0", RUN+="${pkgs.systemd}/bin/systemctl stop ac-power.target" + ACTION!="remove", KERNEL=="AC*", SUBSYSTEM=="power_supply", ATTR{online}=="1", RUN+="${pkgs.systemd}/bin/systemctl start ac-power.target" - KERNEL=="BAT*", SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", RUN+="${pkgs.systemd}/bin/systemctl start battery-power.target" - KERNEL=="BAT*", SUBSYSTEM=="power_supply", ATTR{status}=="Charging", RUN+="${pkgs.systemd}/bin/systemctl stop battery-power.target" + ACTION!="remove", KERNEL=="BAT*", SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", RUN+="${pkgs.systemd}/bin/systemctl start battery-power.target" + ACTION!="remove", KERNEL=="BAT*", SUBSYSTEM=="power_supply", ATTR{status}=="Charging", RUN+="${pkgs.systemd}/bin/systemctl stop battery-power.target" ''; systemd.services.undervolt-intel = {