mirror of
https://github.com/aviallon/nixos-lib.git
synced 2026-04-06 01:38:06 +00:00
[Power] Reduce wrong (battery|ac)-power targets starts issues
This commit is contained in:
parent
a0a3fdf5dc
commit
8ef9c2914a
1 changed files with 7 additions and 6 deletions
13
power.nix
13
power.nix
|
|
@ -96,7 +96,6 @@ in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
systemd.targets.ac-power = {
|
systemd.targets.ac-power = {
|
||||||
description = "Target is active when AC is plugged-in.";
|
description = "Target is active when AC is plugged-in.";
|
||||||
wantedBy = [ "multi-user.target" ];
|
|
||||||
conflicts = [ "battery-power.target" ];
|
conflicts = [ "battery-power.target" ];
|
||||||
unitConfig = {
|
unitConfig = {
|
||||||
ConditionACPower = true;
|
ConditionACPower = true;
|
||||||
|
|
@ -105,16 +104,18 @@ in {
|
||||||
|
|
||||||
systemd.targets.battery-power = {
|
systemd.targets.battery-power = {
|
||||||
description = "Target is active when power is drawn from a battery.";
|
description = "Target is active when power is drawn from a battery.";
|
||||||
wantedBy = [ "multi-user.target" ];
|
|
||||||
conflicts = [ "ac-power.target" ];
|
conflicts = [ "ac-power.target" ];
|
||||||
|
unitConfig = {
|
||||||
|
ConditionACPower = false;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
services.udev.extraRules = ''
|
services.udev.extraRules = ''
|
||||||
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}=="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}=="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"
|
ACTION!="remove", 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}=="Charging", RUN+="${pkgs.systemd}/bin/systemctl stop battery-power.target"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
systemd.services.undervolt-intel = {
|
systemd.services.undervolt-intel = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue