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.

Notes
  • Each string should be either:
  • a bundle ID string as per hs.application:bundleID(), or
  • an application name string as per hs.application:name().
Source Source/PersonalHotspot.spoon/init.lua line 116
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".

Notes
  • 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.
Source Source/PersonalHotspot.spoon/init.lua line 126
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.

Source Source/PersonalHotspot.spoon/init.lua line 134

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
Source Source/PersonalHotspot.spoon/init.lua line 216
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.

Parameters
  • None
Returns
  • Self
Notes
  • 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.
Source Source/PersonalHotspot.spoon/init.lua line 139
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.

Parameters
  • None
Returns
  • Self
Source Source/PersonalHotspot.spoon/init.lua line 172
toggle
Signature PersonalHotspot:toggle() -> Self
Type Method
Description

Toggles personal hotspot connection.

Parameters
  • None
Returns
  • Self
Notes
  • If the current wireless network name is PersonalHotspot.hotspotName this method calls PersonalHotspot:disconnect(), otherwise this method will call PersonalHotspot:connect().
Source Source/PersonalHotspot.spoon/init.lua line 194