| Newsgroups |
gmane.emacs.help |
| Message-ID |
<[email protected]> |
On 2026-03-01, at 12:13, Stéphane Marks <[email protected]> wrote:
> On Sun, Mar 1, 2026 at 12:09 PM <[email protected]> wrote:
>
> On 2026-03-01, at 03:48, Stéphane Marks <[email protected]> wrote:
>
> > You could give the new `system-sleep` package a try that is in Emacs 31 from master. Register a hook on
> > `system-sleep-event-functions` and your hook will be notified when the system is about to sleep or has woken up. This
> will be
> > more reliable than relying on timers, though, if you want to defer some of the work you could set a one-shot timer upon
> waking
> > to do your work.
>
> Ha, I had no idea this existed, thanks! From a cursory reading it seems
> that this feature is in its early days - it gives me a bit of a vibe of
> an unpolished prototype - but it's definitely a great addition to Emacs!
> I will certainly blog about is, since it is potentially very useful.
> (Not to mention that it seems to bring Emacs even closer to an operating
> system;-)).
>
> Prototype is in the eye of the beholder, I suppose. It runs on Linux/D-Bus, MS-Windows, macOS/NS and has been used already
> by other people. Try it and if you find an issue let us know.
Ha, sorry again for poor wording. The prototype-ish feeling I had was
the result of seeing this in the docs:
--8<---------------cut here---------------start------------->8---
-- User Option: system-sleep-event-functions
When the system is about to enter a sleep state or after it wakes
from one, each function on this abnormal hook is called with one
argument, EVENT, a sleep event. Its state can be retrieved via
‘‘(sleep-event-state event)’’. State will be one of the symbols
‘pre-sleep’ or ‘post-wake’.
--8<---------------cut here---------------end--------------->8---
However, I couldn't find the source code for `sleep-event-state'.
Anyway, I'll definitely try system-sleep.
Thanks again!
--
Marcin Borkowski
https://mbork.pl