You are not logged in.
Hi there,
I used to use the following rule to start a service from an udev rule:
SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="0", RUN+="/usr/bin/systemctl start powersaving.service"
SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="1", RUN+="/usr/bin/systemctl start powersaving.service"
This rule successfully runs the service. I changed this to the - what I believe - correct way:
SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="0", TAG+="systemd", ENV{SYSTEMD_WANTS}="powersaving.service"
SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="1", TAG+="systemd", ENV{SYSTEMD_WANTS}="powersaving.service"
This rule no longer runs the service, nor is there any log output. Am I missing something?
The respective service file:
[Unit]
Description=Run powersaving script depending on AC state
[Service]
Type=oneshot
Environment=DISPLAY=:0
Environment=XAUTHORITY=/home/orschiro/.Xauthority
ExecStart=/usr/bin/powersaving
[Install]
WantedBy=multi-user.target
Last edited by orschiro (2014-05-05 11:25:07)
Offline
TAG is not a list; so
TAG+="systemd"
is not correct.
Sorry I answered too quickly.
Last edited by berbae (2014-05-04 15:27:22)
Offline
This one works, too:
SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="0", RUN+="/usr/bin/systemctl --no-block start powersaving.service"
SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="1", RUN+="/usr/bin/systemctl --no-block start powersaving.service"
Offline
If that works stay with it.
Is not 'ENV{SYSTEMD_WANTS}=' for .device units only? (not sure)
See 'man systemd.device'.
Offline
Good point. So I would have to bind my service specifically to a device unit - in that case the power system - ?
In any case, I will stick to the working variant for now.
Thanks for your help!
Offline