hammerspoon2-docs
    Preparing search index...

    Function on

    • Register a listener for system power/session events, or battery state changes.

      Parameters

      • event: HSPowerEvent

        The event to listen for. "change" fires whenever battery state changes; the rest are system power/session events.

      • listener: () => void

        Called with no arguments when the event occurs; call batteryInfo() inside a "change" listener to inspect the new battery state

      Returns void

      Throws an Error on failure; wrap calls in try/catch to handle it.