hammerspoon2-docs
    Preparing search index...

    Class HSWifiWatcher

    A Wi-Fi event watcher that monitors changes to a Wi-Fi interface. Create via hs.wifi.addWatcher(). Set a callback with setCallback(), then call start() to begin receiving events. By default only "ssidChange" is watched; use the events property to watch other event types.

    Event Info keys
    "ssidChange" interface: string
    "bssidChange" interface: string
    "countryCodeChange" interface: string
    "linkChange" interface: string
    "linkQualityChange" interface: string, rssi: number, transmitRate: number
    "modeChange" interface: string
    "powerChange" interface: string
    "scanCacheUpdated" interface: string
    Index

    Constructors

    Properties

    Methods

    Constructors

    Properties

    events: string[]

    The event types this watcher will invoke its callback for. Defaults to ["ssidChange"]. Unrecognized values are ignored with a console warning; see hs.wifi.watcherEventTypes for the list of valid values. Can be changed while the watcher is running.

    identifier: string

    The unique identifier assigned to this watcher.

    Methods

    • Stops the watcher and releases all resources. Called automatically during shutdown.

      Returns void

    • Sets the callback function invoked when a watched Wi-Fi event occurs.

      Parameters

      • fn: (event: string, info: Record<string, any>) => void

        Called with the event name and an info dictionary; see type documentation for event names and info keys.

      Returns HSWifiWatcher

      self, for chaining