Hammerspoon / Spoons

The official repository of Spoon plugins
https://www.hammerspoon.org/Spoons/
450 stars 141 forks source link

PersonalHotspot spoon does not work on macOS 12 #275

Open dschuessler opened 2 years ago

dschuessler commented 2 years ago

The following sample code does nothing:

spoon.SpoonInstall:andUse(
  "PersonalHotspot",
  {
    config = {
      hotspotName = "iPhone",
    },
  }
)

spoon.PersonalHotspot:connect()

I had a look into the spoon's code and it is apparently supposed to open the Wi-Fi menu bar item and click on the entry. When I copy the relevant Javascript code over to macOS' script editor, it already fails to fetch the menu bar item:

Error: TypeError: undefined is not an object (evaluating 'wifiMenuBarItem.menus')

This might be a result of somewhat recent macOS updates. I can't find an easy solution right away but I leave this here for reference, in case I get around having a closer look.

malob commented 2 years ago

I'll have a look into this on the weekend.

dschuessler commented 2 years ago

When I tried to fix it myself, I stumbled over a great writeup about scripting the menu bar in Big Sur by @geofftaylor.

Ultimately, I didn't succeed. (UI Browser fails to break down the UI item hierarchy of the Wi-Fi menu, at least on my machine with macOS 12.) But I leave it here in case it helps.