Skip to content

Instantly share code, notes, and snippets.

@pandrewhk
Forked from jellea/wifi.lua
Last active November 23, 2020 11:15
Show Gist options
  • Save pandrewhk/e781c51c3de7ee47fe8ba3a6c0f3d2a1 to your computer and use it in GitHub Desktop.
Save pandrewhk/e781c51c3de7ee47fe8ba3a6c0f3d2a1 to your computer and use it in GitHub Desktop.
function ssidChangedCallback()
newSSID = hs.wifi.currentNetwork()
if newSSID ~= lastSSID then
hs.alert.show("WiFi changed, muting speakers", 5)
hs.audiodevice.findOutputByName("MacBook Pro Speakers"):setOutputVolume(20)
hs.audiodevice.findOutputByName("MacBook Pro Speakers"):setOutputMuted(true)
end
lastSSID = newSSID
end
wifiWatcher = hs.wifi.watcher.new(ssidChangedCallback)
wifiWatcher:start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment