You are not logged in.

#1 2013-02-14 03:42:33

NClement
Member
Registered: 2011-11-13
Posts: 8

[SOLVED] Systemd "lid open" hook?

Hi,

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)

Offline

#2 2013-02-14 04:08:55

snakeroot
Member
Registered: 2012-10-06
Posts: 103

Re: [SOLVED] Systemd "lid open" hook?

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.

Regards,

Offline

#3 2013-02-14 04:24:00

progandy
Member
Registered: 2012-05-17
Posts: 2,151

Re: [SOLVED] Systemd "lid open" hook?

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)

Offline

#4 2013-02-14 04:26:05

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,412

Re: [SOLVED] Systemd "lid open" hook?

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.

Offline

#5 2013-02-14 06:04:53

NClement
Member
Registered: 2011-11-13
Posts: 8

Re: [SOLVED] Systemd "lid open" hook?

Thanks!

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 wink )

Offline

Board footer

Powered by FluxBB