Add power-connected/disconnected systemd targets

This commit is contained in:
ItsDrike 2023-03-28 02:47:34 +02:00
parent bc3a65ba93
commit 5972b65e95
Signed by: ItsDrike
GPG key ID: FA2745890B7048C0
3 changed files with 13 additions and 0 deletions

View file

@ -0,0 +1,5 @@
Description=Power adapter is connected (charger plugged)
Conflicts=power-disconnected.target
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,6 @@
[Unit]
Description=Power adapter is disconnected (charger NOT plugged)
Conflicts=power-connected.target
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,2 @@
SUBSYSTEM=="power_supply", ATTR{online}=="1", RUN+="/bin/systemctl start power-connected.target"
SUBSYSTEM=="power_supply", ATTR{online}=="0", RUN+="/bin/systemctl start power-disconnected.target"