Skip to content

Instantly share code, notes, and snippets.

@yam-liu
Created September 11, 2020 16:51
Show Gist options
  • Save yam-liu/39570b414bd492c86d2a2e72b5315ac9 to your computer and use it in GitHub Desktop.
Save yam-liu/39570b414bd492c86d2a2e72b5315ac9 to your computer and use it in GitHub Desktop.
WiFi Change Action
local prevSSID = 'NO_NET'
function ssidChangedCallback()
local ssid = hs.wifi.currentNetwork()
if ssid ~= nil then
print(prevSSID .. " -> " .. ssid)
if ssid ~= nil and ssid ~= prevSSID then
prevSSID = ssid
hs.notify.show('Wi-Fi changed to ' .. (ssid), '', '')
if ssid == 'AAA' then
hs.application.open('/Applications/ZZZ.app')
elseif string.match(string.lower(ssid), 'BBB') then
hs.osascript.applescript('quit app "ZZZ"')
end
end
end
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