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

From: Eli Zaretskii <[email-masked]>
Date: Fri, 07 Feb 2025 14:18:20 +0200

> Date: Fri, 7 Feb 2025 19:43:32 +0800 (GMT+08:00)
> From: Andrew Cohen <[email-masked]>
> Cc: [email-masked], Stefan Monnier <[email-masked]>,
> 	Eli Zaretskii <[email-masked]>, [email-masked]
> 
> Having thought a bit more I am convinced that starting the block 
> before the sleep notification is the right thing

This sounds strange to me.  Are you absolutely sure?  Did you try this
on some system?  Why would an application need to proactively block
sleep mode before the system announces its intention to sleep?  Won't
doing that prevent sleep, including one due to system idleness,
altogether?

> I think that with logind putting the block on AFTER the notification
> is actually not allowed (at least it seems that way in my testing.

We don't need to block sleep, we only need to delay it for a short
while.

> Can I get any feedback about the file descriptor closure issue? From what 
> I can tell without exposing it in lisp the way I did I won't be able to 
> use blocking anyway.

Emacs has no way of manipulating handles or file descriptors.  If this
is required in this case, we must expose it to Lisp in the form of
some primitive.

But since there could be only one such descriptor at any given time,
why would any Lisp program need to know its value?  It sounds like we
need to record the descriptor internally, and then close it in C, no?
Maybe some D-Bus related primitive could do that?