Re: [GNU ELPA] New package: caffeinate-mode
Lucas Christian <[email protected]>
| Newsgroups | gmane.emacs.devel |
|---|---|
| Message-ID | <[email protected]> |
Stéphane Marks <[email protected]> writes: > On Mon, Jul 20, 2026 at 1:56 PM Philip Kaludercic <[email protected]> wrote: > > Lucas Christian <[email protected]> writes: > > > Philip Kaludercic <[email protected]> writes: > > > > The main challenge here is that I as a user have to remember what > > setting the mode was last in. E.g. if I last used caffeinate with > > display sleep blocking, but now I just want system sleep blocking, I > > would need to run M-x caffeinate-mode followed by M-x > > caffeinate-toggle-inhibit-display-sleep. Whereas with the separate minor > > modes, I just call the one I want. Perhaps that's not that big of a deal > > though--if someone really feels strongly they can add a few trivial > > functions to their init to turn on caffeinate to the preference value > > that they want. > > I am not familiar with the system-sleep API, do you think it is feasible > to have the option change the behavior of an existing process? > > FWIU, caffeinate-mode is not process specific, it's a user-level all-or-nothing election. To switch from its global display > allowed to sleep to display not allowed to sleep it has to cancel its sleep token and request a new one with the display option > specified. I believe it does that now. The caffeinate-mode UI for selecting between display sleep or not is the open > question, I think, not the mechanism of action. This is correct--to switch between blocking only system sleep, or blocking system + display sleep, you have to drop the system-sleep assertion and acquire a new one. > For integrations like gnus, it relies only on being notified that the > system has gone to sleep or awakened and does not itself dictate any > policy. True, it's worth calling out that there are two functions of the system-sleep package: 1. The package provides notifications when the system is about to go to sleep, and when the system has re-awakened from sleep. 2. The package provides a "power assertion" API, that allows packages to request that the system does not go to sleep. caffeinate-mode is only focused on the second function. For what it's worth, on my branch of gnus, I integrated both. I use 1 to disable the gnus demon from attempting to check for new news when the system is asleep or right after waking (when network access is usually still re-establishing, so TCP connections almost always stall). I also use 2 to keep the system from going to sleep mid-operation (fetching new news or downloading articles offline with the gnus-agent). -- Lucas Christian [email protected]