#hs.battery.watcher

Watch for battery/power state changes

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


#API Overview

Constructors - API calls which return an object, typically one that offers API methods

Methods - API calls which can only be made on an object returned by a constructor


#API Documentation

#Constructors

Signaturehs.battery.watcher.new(fn) -> watcher
TypeConstructor
DescriptionCreates a battery watcher
Parameters
  • A function that will be called when the battery state changes. The function should accept no arguments.
Returns
  • An hs.battery.watcher object
Notes
ExamplesNone
Sourceextensions/battery/libbattery_watcher.m line 44

#Methods

Signaturehs.battery.watcher:start() -> self
TypeMethod
DescriptionStarts the battery watcher
Parameters
  • None
Returns
  • The hs.battery.watcher object
NotesNone
ExamplesNone
Sourceextensions/battery/libbattery_watcher.m line 75

Signaturehs.battery.watcher:stop() -> self
TypeMethod
DescriptionStops the battery watcher
Parameters
  • None
Returns
  • The hs.battery.watcher object
NotesNone
ExamplesNone
Sourceextensions/battery/libbattery_watcher.m line 97