I was trying to create a simple(ish) way to detect whether my laptop lid was closed and activate i3lock when it is. I know that this can be done through acpid or other methods, but I wanted to learn more about systemd timers anyway, so I went that way. It turns out that systemd has special units for timers, and one of them is for sleep, but I was unable to find anything online telling me how to do this, even on the usually amazing arch wiki. Does anyone know how to set up a service/timer to activate on these special units?
1 Answer
sleep.target
is a target, so you name it in a WantedBy
setting in your service unit file, and then enable the service.
Further reading
- "Sleep hooks". Power management. Arch wiki.
Requires=
orAfter=
declaration in your service file.