Hammerspoon / hammerspoon

Staggeringly powerful macOS desktop automation with Lua

Home Page:http://www.hammerspoon.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`hs.wifi` not showing current network in Sonoma 14.2.1

andreoliwa opened this issue Β· comments

πŸ‘‹πŸ» It seems that something is off with hs.wifi.currentNetwork() after I upgraded macOS to Sonoma.

I added this to init.lua for debugging:

local networks = hs.wifi.availableNetworks()
print('WiFi available:')
for i, network in ipairs(networks) do
    print(i, network)
end
local interfaces = hs.wifi.interfaces()
print('WiFi interfaces:')
for i, interface in ipairs(interfaces) do
    print(i, interface)
end
local currentNetwork = hs.wifi.currentNetwork()
if currentNetwork then
    print('WiFi network: ' .. currentNetwork)
else
    print('WiFi network: Not connected')
end

This is the output:

2024-01-23 11:29:55: -- Loading extension: wifi
2024-01-23 11:29:58: WiFi available:
2024-01-23 11:29:58: WiFi interfaces:
2024-01-23 11:29:58: 1	en0
2024-01-23 11:29:58: WiFi network: Not connected

This is a laptop administered by my company with an inventory tracking app running in the background.
I have full admin/root/sudo permissions, though.
I don't know if this is somehow related since Sonoma started asking for my authorisation in other places.

I don't know how to debug it further, any ideas?

It looks like there was a change in permissions in Sonoma. Location Services has to be enabled and the app has to request access to be able to see the ssid property.