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

From: Ship Mints <[email-masked]>
Date: Fri, 7 Feb 2025 06:13:34 -0500

On Fri, Feb 7, 2025 at 2:14 AM Andrew Cohen <[email-masked]> wrote:

>
> I spent some time looking over the documentation and the general
> recommendations for dealing with sleep notifications. The recommendation
> (from systemd/logind) is that any application that needs to do something
> prior to sleep should monitor for sleep notifications and install the
> block preventing sleep at the time that monitoring starts. When a
> notification of sleep is received the application should complete its
> work and then remove the block. After waking up, the block should be
> restored.

The semantics on macOS are still a bit murky to me and the API is woefully
under documented. The steps on macOS, I think, will be what we discussed
earlier where the block is put in place during sleep-request handling. I
will see if it is possible to follow the same method as gnome but it may
have to be through experimentation (that'll be super fun).

The other thing I was able to find in documentation from last decade is
that there are two kinds of sleep, kind of as you'd expect:

- Forced sleep where the user explicitly does something like closing a
laptop lid or pressing a sleep button. This kind of sleep can be briefly
delayed but not blocked by an application.

- Inactive sleep where the system sleeps on user idleness. This kind of
sleep can be both delayed and blocked.

Let's keep the potential semantics and processing differences in mind when
designing how to make this work across platforms. It may be possible to
have one system implementation emulate another but that could be cumbersome
vs. a more accommodative structure.