Documentation

Commentary

Call `system-sleep-block-sleep' to inhibit system-wide idle sleep.
Idle sleep is typically triggered when the system does not detect
user activity and is independent of any processing that may be on
going.  This function is useful to block idle sleep for long-running
operations, for example, when a compilation is running.  You have the
option of keeping the system active while letting the display sleep.
This function returns a token which you must use to unblock this
request.

Call `system-sleep-unblock-sleep' with the token from
`system-sleep-block-sleep' to unblock system-wide idle sleep for this
request.  There may be other active requests which will prevent the
system from sleeping.

The function `system-sleep-sleep-blocked-p' will tell you if
`system-sleep' has any active system sleep blocks.

Note: When the Emacs process dies, blocks are released on all
platforms.

You can register functions on the abnormal hook
`system-sleep-event-functions'.  Each function will be called when
the system is preparing for sleep and when the system wakes from
sleep.  These functions are useful when you want to close (and
potentially reopen) external connections or serial ports.

On supported GNU/Linux systems, the implementation is via D-Bus to
inhibit idle sleep, keep the display active, and forward events from
logind for system sleep events.

On macOS and MS-Windows, native APIs are used to block idle sleep,
keep the display active, and provide sleep event notifications.

On MS-Windows, an idle sleep block that keeps the display active may
not inhibit the screen saver.

Externally to Emacs, there are system utility functions that you can
use to inspect all processes on your system that might be blocking it
from sleeping.

On D-Bus systems, you can use the commands:

  systemd-inhibit --list
or
  dbus-send --system --print-reply --dest=org.freedesktop.login1 \
  /org/freedesktop/login1 \
  org.freedesktop.login1.Manager.ListInhibitors

Note: You can find the sleep/shutdown delay InhibitDelayMaxUSec in
the file logind.conf(5) which typically defaults to 5 seconds.

On macOS, you can use the command:

  pmset -g assertions

On MS-Windows, you can use the following command which may need to be
run as an administrator:

  powercfg -requests

Requires

Dependencies

Consumers

Reverse Dependencies

No reverse dependencies recorded.