caffeinate

Last updated 6 months ago

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

API Documentation

Functions

Signature

hs.caffeinate.declareUserActivity([id])

Type

Function

Description

Informs the OS that the user performed some activity

Parameters

Returns

Notes

get

Signature

hs.caffeinate.get(sleepType) -> bool or nil

Type

Function

Description

Queries whether a particular sleep type is being prevented

Parameters

Returns

Signature

hs.caffeinate.lockScreen()

Type

Function

Description

Request the system lock the displays

Parameters

Returns

logOut

Signature

hs.caffeinate.logOut()

Type

Function

Description

Request the system log out the current user

Parameters

Returns

Signature

hs.caffeinate.restartSystem()

Type

Function

Description

Request the system reboot

Parameters

Returns

Signature

hs.caffeinate.sessionProperties()

Type

Function

Description

Fetches information from the display server about the current session

Parameters

Returns

Notes

set

Signature

hs.caffeinate.set(sleepType, aValue, acAndBattery)

Type

Function

Description

Configures the sleep prevention settings

Parameters

Returns

Notes

Signature

hs.caffeinate.shutdownSystem()

Type

Function

Description

Request the system log out and power down

Parameters

Returns

Signature

hs.caffeinate.startScreensaver()

Type

Function

Description

Request the system start the screensaver (which may lock the screen if the OS is configured to do so)

Parameters

Returns

Signature

hs.caffeinate.systemSleep()

Type

Function

Description

Requests the system to sleep immediately

Parameters

Returns

toggle

Signature

hs.caffeinate.toggle(sleepType) -> bool or nil

Type

Function

Description

Toggles the current state of the specified type of sleep

Parameters

Returns

Notes