GNU bug report logs - #63620
30.0.50; [Feature Request] run hooks on sleep/wake

Previous Next

Package: emacs;

Reported by: Andrew Cohen <acohen <at> ust.hk>

Date: Sat, 20 May 2023 23:25:02 UTC

Severity: wishlist

Tags: patch

Found in version 30.0.50

Full log


Message #154 received at 63620 <at> debbugs.gnu.org (full text, mbox):

From: Andrew Cohen <acohen <at> ust.hk>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 63620 <at> debbugs.gnu.org, michael.albinus <at> gmx.de, monnier <at> iro.umontreal.ca
Subject: Re: bug#63620: 30.0.50; [Feature Request] run hooks on sleep/wake
Date: Thu, 06 Feb 2025 23:36:34 +0800
>>>>> "EZ" == Eli Zaretskii <eliz <at> gnu.org> writes:

[...]

    EZ> What is the semantics of this?  If the user closes the lid of
    EZ> the laptop, and that was defined to put the system to sleep,
    EZ> does such "inhibiting" mean the system will not sleep?  If so,
    EZ> I'm not sure this is supported.  Or do you mean to delay sleep
    EZ> which is triggered by prolonged enough lack of activity?

The former.  Here is how it works for logind (which is common for
gnu/linux desktops):

logind, as part of the desktop system,  takes responsibility for sleep
initiated through the desktop: that is, through a lack of activity, an
explicit hibernate command (maybe a keypress or a menu item) or through
a lid switch, for example. When a sleep request is initiated this way,
it is announced through D-Bus (the PrepareForSleep signal); D-Bus also
has methods that can control the behavior. An "Inhibit" method can be
called which inhibits the sleep process, even if the lid is now closed,
for example. (This inhibition can just be a delay, or it can be a full
block depending on the parameters passed to "Inhibit"); as long as the
block is in place the system will not sleep. The "Inhibit" method
returns a file descriptor, and the block remains in force until the file
descriptor is closed.

It is, of course, possible to trigger hibernation outside of the desktop
system (directly to the kernel, for example), and this is not controlled
through D-Bus.

My daily routine involves a laptop moving from home to office, and I
rarely log out of the desktop or shutdown. So I typically just shut the
lid which triggers hibernation, and rely on sleep-wake-mode to manage
gnus network connections and my vpn. I had never bothered inhibiting the
sleep since Emacs was always fast enough to complete in time, but the
right thing is certainly to call the "Inhibit" method. Other systems are
likely different.

Best,
Andy

-- 
Andrew Cohen




This bug report was last modified 131 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.