Re: [GNU ELPA] New package: caffeinate-mode

Philip Kaludercic <[email protected]>
Newsgroups gmane.emacs.devel
Message-ID <[email protected]>
Lucas Christian <[email protected]> writes:

> Hi all,
>
> Long-time Emacs user, first-time contributing a package.
>
> One of the more practical additions I am excited about in Emacs 31 is
> the system-sleep package, which provides a native hook into the
> operating system's power management APIs.  Long-term, I suspect the
> potential of system-sleep will come from it being integrated into many
> Emacs workflows so that the user never has to think about preventing
> their system from going to sleep while Emacs executes long-running
> tasks.  Until then, I wrote this package to get system-sleep in front of
> many users by offering a simple proposition: it can replace the GUI or
> external command line tool they are likely already using.
>
> caffeinate-mode solves the simple and generic case of "I started some
> long-running task (that doesn't integrate directly with the OS power
> management APIs), I want to manually tell the system not to sleep so it
> can complete without interruption".  Users may already be using various
> utilities for this such as "Caffeine" (GNOME extension or macOS app by
> the same name), systemd-inhibit (Linux CLI tool), or caffeinate (macOS
> equivalent).  

(Android also has an option by this name.  I didn't know what it does for
a long time, but apparently this term is becoming more standard.)

>               On previous versions of Emacs, I frequently found myself
> launching "caffeinate" from M-x async-shell-command for these use cases.
>
> Package description:
>
>   This package provides two global minor modes that can be toggled on
>   any time it would be inopportune for the system to sleep:
>
>   - caffeinate-mode blocks system idle sleep but allows the display to
>     sleep.
>
>   - display-caffeinate-mode blocks system idle sleep and also keeps the
>     display active.

>   The modes are mutually exclusive: enabling one automatically disables
>   the other.  Disabling either mode releases the active power assertion,
>   allowing the system to resume its normal sleep behavior.

I don't get why you need two separate options for this, can you not have
one major mode with two values (recall that each minor mode is also a
user option)?  You can use a prefix argument in an interactive setting
to force the other mode, depending on which of the two you consider to
be more interesting.

>
>   While the modes are active, Caffeinate signals your operating system
>   using its native power assertion APIs, using the facilities provided
>   by the system-sleep package.
>
>   If you frequently forget to disable caffeinate-mode, you can set a
>   timeout using caffeinate-set-timeout (or the options in the mode-line
>   menu) to ensure your system will eventually sleep.
>
> Repository: https://github.com/lucasec/emacs-caffeinate
>
> Dependencies: This package only works on Emacs 31+ (since Emacs 31 is
>   not released yet, I appreciate any advice on how to set the
>   Package-Requires line)

The code looks fine otherwise, and we can add it to ELPA even before
we release Emacs 31.1.  Just some minor nits:

- For GNU ELPA, you'll have to adjust the copyright line to "Free
  Software Foundation, Inc.", just like with all the files in emacs.git.

- I would personally set the minimum version to 31.0.90 to avoid
  confusion with old builds from pre-prerelease that did not have
  system-sleep failing.  I'd probably bump it to 31.1 when the final
  release is cut, if for no reason than to help disincentives people
  from using old development builds.

> My intention is to submit this package to GNU ELPA. I do not currently
> have an FSF copyright assignment on file but would be happy to complete
> one.

This is a blocker for progressing anyway right now, but Eli or Sean will
send you a copy of the form to fill out to get the process started.
Just ping me when there is news and we can progress.

> Best,
> Lucas
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.