Skip to content
This repository has been archived by the owner on Jun 9, 2023. It is now read-only.

Latest commit

 

History

History
132 lines (109 loc) · 9.99 KB

hs.caffeinate.watcher.md

File metadata and controls

132 lines (109 loc) · 9.99 KB

docs » hs.caffeinate.watcher


Watch for display and system sleep/wake/power events and for fast user switching session events.

This module is based primarily on code from the previous incarnation of Mjolnir by Steven Degutis.

API Overview

API Documentation

Constants

Signature hs.caffeinate.watcher.screensaverDidStart
Type Constant
Description The screensaver started
Signature hs.caffeinate.watcher.screensaverDidStop
Type Constant
Description The screensaver stopped
Signature hs.caffeinate.watcher.screensaverWillStop
Type Constant
Description The screensaver is about to stop
Signature hs.caffeinate.watcher.screensDidLock
Type Constant
Description The screen was locked
Signature hs.caffeinate.watcher.screensDidSleep
Type Constant
Description The displays have gone to sleep
Signature hs.caffeinate.watcher.screensDidUnlock
Type Constant
Description The screen was unlocked
Signature hs.caffeinate.watcher.screensDidWake
Type Constant
Description The displays have woken from sleep
Signature hs.caffeinate.watcher.sessionDidBecomeActive
Type Constant
Description The session became active, due to fast user switching
Signature hs.caffeinate.watcher.sessionDidResignActive
Type Constant
Description The session is no longer active, due to fast user switching
Signature hs.caffeinate.watcher.systemDidWake
Type Constant
Description The system woke from sleep
Signature hs.caffeinate.watcher.systemWillPowerOff
Type Constant
Description The user requested a logout or shutdown
Signature hs.caffeinate.watcher.systemWillSleep
Type Constant
Description The system is preparing to sleep

Constructors

Signature hs.caffeinate.watcher.new(fn) -> watcher
Type Constructor
Description Creates a watcher object for system and display sleep/wake/power events
Parameters
  • fn - A function that will be called when system/display events happen. It should accept one parameter:
  • An event type (see the constants defined above)
Returns
  • An hs.caffeinate.watcher object

Methods

Signature hs.caffeinate.watcher:start()
Type Method
Description Starts the sleep/wake watcher
Parameters
  • None
Returns
  • An hs.caffeinate.watcher object
Signature hs.caffeinate.watcher:stop()
Type Method
Description Stops the sleep/wake watcher
Parameters
  • None
Returns
  • An hs.caffeinate.watcher object