docs » PersonalHotspot

Connect, disconnect, or toggle connection to/from a personal hotspot. Optionally kills/opens a list of apps on connect/disconnect respectively.

Example configuration (using SpoonInstall.spoon):

spoon.SpoonInstall:andUse(
  "PersonalHotspot",
  {
    config = {
      hotspotName = "John Appleseed’s iPhone",
      appsToKill = {
        "Arq",
        "Arq Agent",
        "Dropbox"
      }
    },
    hotkeys = {
      toggle = {{"cmd", "option", "ctrl"}, "h"}
    }
  }
)

If PersonalHotspot.hotspotName isn't set, the first personal hotspot in the Wi-Fi menu will be selected, and PersonalHotspot.hotspotName will be set to the name of that hotspot.

API Overview

API Documentation

Variables

appsToKill
Signature PersonalHotspot.appsToKill (List)
Type Variable
Description

A list of strings representing applications to kill/open, when PersonalHotspot:connect() and PersonalHotspot:disconnect() are called respectively.

Each string should be either:

  • a bundle ID string as per hs.application:bundleID(), or
  • an application name string as per hs.application:name().
hotspotName
Signature PersonalHotspot.hotspotName (String)
Type Variable
Description

The name of the personal hotspot you want to connect/disconnect from, e.g., "John Appleseed’s iPhone".

You can see the names of available hotspots by clicking on the Wi-Fi icon in the macOS menu bar and looking for menu items under the "Personal Hotspot(s)" heading.

timeout
Signature PersonalHotspot.timeout (Number)
Type Variable
Description

The number of seconds to wait for personal hotspot to appear in Wi-Fi menu before attempting to connect/disconnect. Default is 3 seconds.

Methods

bindHotkeys
Signature PersonalHotspot:bindHotkeys(mapping) -> Self
Type Method
Description

Binds hotkey mappings for this spoon.

Parameters:

  • mapping (Table) - A table with keys who's names correspond to methods of this spoon, and values that represent hotkey mappings. For example:
    • { toggle = { {"cmd", "option", "ctrl" }, "h" }

Returns:

  • Self
connect
Signature PersonalHotspot:connect() -> Self
Type Method
Description

Tries to connect to the personal hotspot named in PersonalHotspot.hotspotName. If PersonalHotspot.hotspotName is nil, the first hotspot in the Wi-Fi menu will be selected, and PersonalHotspot.hotspotName will be assigned to the name of that hotspot. Once connected to the hotspot, the applications specified in PersonalHotspot.appsToKill are killed.

If there are no hotspots with the name in PersonalHotspot.hotspotName, or if PersonalHotspot.hotspotName is nil and there are no hotspots in the Wi-Fi menu, the Wi-Fi menu will be closed after PersonalHotspot.timeout seconds.

Returns:

  • Self
disconnect
Signature PersonalHotspot:disconnect() -> Self
Type Method
Description

If currently connected to the personal hotspot named in PersonalHotspot.hotspotName, this method will disconnect from that hotspot and open the applications specified in PersonalHostspot.appsToKill.

Returns:

  • Self
toggle
Signature PersonalHotspot:toggle() -> Self
Type Method
Description

Toggles personal hotspot connection.

If the current wireless network name is PersonalHotspot.hotspotName this method calls PersonalHotspot:disconnect(), otherwise this method will call PersonalHotspot:connect().

Returns:

  • Self