Let me first say what I wish to accomplish:
I want my laptop to suspend 5 minutes after the lid is closed, except if I open the lid again before the 5 minutes are up, I want it to stop waiting to suspend and just not suspend at all.
Is there some sort of systemd hook that I can use to run "killall systemd-sleep" when I open my laptop lid?
Last edited by NClement (2013-02-14 06:05:35)
Not sure if this can be accomplished using systemd. The HandleLidSwitch in logind.conf is limited to ignore, poweroff, reboot, halt, kexec, suspend, hibernate, hybrid-sleep and lock. So its not like you can use it to start a timer.
There are also inhibitor locks (which can prevent or delay suspend). Unfortunately the lid switch ones are limited to block rather than including delay.
I think you have to create your own daemon to monitor these events and inhibit systemd (systemd will handle it if your daemon is not running) or use acpid (and set systemd to always ignore)
Go the acpid route. It is simple and easy. The alternative would be to create scripts that are called by udev itself, but I think the simplicity of acpid is why it was created, so you might as well use it.
The acpid idea worked. In case someone else wants to do the same:
1) I set "HandleLidSwitch=ignore" in /etc/systemd/logind.conf
2) Ran "systemctl enable acpid"
3) In /etc/acpi/handler.sh I have:
... button/lid) case "$3" in close) logger 'LID closed' /etc/acpi/scripts/lid-close & ;; open) logger 'LID opened' /etc/acpi/scripts/lid-open & ;; ...
where the first script waits a while, then does "systemctl suspend" and the second script does "killall lid-close" to kill the first one (and anything else by the same name )