#
hs.caffeinate
Control system power states (sleeping, preventing sleep, screen locking, etc)
NOTE: Any sleep preventions will be removed when hs.reload() is called. A future version of the module will save/restore state across reloads.
#
Submodules
#
API Overview
Functions - API calls offered directly by the extension
currentAssertions declareUserActivity fastUserSwitch get lockScreen logOut restartSystem sessionProperties set shutdownSystem startScreensaver systemSleep toggle
#
API Documentation
#
Functions
#
currentAssertions
#
declareUserActivity
#
fastUserSwitch
#
get
#
lockScreen
#
logOut
#
restartSystem
#
sessionProperties
#
set
| | |
| --------------------------------------------|-------------------------------------------------------------------------------------|
| Signature | hs.caffeinate.set(sleepType, aValue, acAndBattery)
|
| Type | Function |
| Description | Configures the sleep prevention settings |
| Parameters |
- sleepType - A string containing the type of sleep to be configured. The value should be one of: displayIdle - Controls whether the screen will be allowed to sleep (and also the system) if the user is idle. systemIdle - Controls whether the system will be allowed to sleep if the user is idle (display may still sleep). system - Controls whether the system will be allowed to sleep for any reason.
- aValue - A boolean, true if the specified type of sleep should be prevented, false if it should be allowed
- acAndBattery - A boolean, true if the sleep prevention should apply to both AC power and battery power, false if it should only apply to AC power.
- None
- These calls are not guaranteed to prevent the system sleep behaviours described above. The OS may override them if it feels it must (e.g. if your CPU temperature becomes dangerously high).
- The acAndBattery argument only applies to the
system
sleep type. - You can toggle the acAndBattery state by calling
hs.caffeinate.set()
again and altering the acAndBattery value. - The acAndBattery option does not appear to work anymore - it is based on private API that is not allowed in macOS 10.15 when running with the Hardened Runtime (which Hammerspoon now uses).