Subject: bug#63620: 30.0.50; [Feature Request] run hooks on sleep/wake

From: Andrew Cohen <[email-masked]>
Date: Fri, 07 Feb 2025 22:41:39 +0800

>>>>> "EZ" == Eli Zaretskii <[email-masked]> writes:

[...]

    EZ> For our reaction to the system's notification of an imminent
    EZ> sleep mode, I'm surprised that we'd need to block sleep up
    EZ> front.  It should not be needed.  Like macOS and MS-Windows, I
    EZ> believe GNU/Linux provides the application with an ability to
    EZ> delay sleep, so that the application could do what it needs in
    EZ> preparation for the sleep.

With logind, delaying sleep and blocking sleep are done in exactly the
same way: by calling an "Inhibit" method that returns a file
descriptor. Closing the descriptor removes the block and sleep can
proceed. The only difference is that with the delay case the sleep
proceeds after some (configurable) time even if the file descriptor is
not closed.

The documentation makes clear that the block (either for a hard block or
one with a delay) should be done at the time a monitor is installed to
watch for the sleep signal, and not wait for the signal to be generated,
which might be too late.

-- 
Andrew Cohen