hammerspoon2-docs
    Preparing search index...

    Function on

    • Register a listener for Bluetooth events.

      Listeners receive:

      • "connected", "disconnected": the HSBluetoothDevice that macOS connected or disconnected. For Hammerspoon's own connections to BLE peripherals, listen on the HSBluetoothPeripheral instead.
      • "powerChanged": true when Bluetooth is turned on, false when it's turned off
      • "discovered": each HSBluetoothPeripheral found while hs.bluetooth.scan() runs

      Parameters

      • event: "connected" | "disconnected" | "powerChanged" | "discovered"

        The event to listen for

      • listener: (arg: boolean | HSBluetoothDevice | HSBluetoothPeripheral) => void

        Called with the event's device or peripheral, or for "powerChanged" the new power state

      Returns void

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