Created
September 11, 2020 16:51
-
-
Save yam-liu/39570b414bd492c86d2a2e72b5315ac9 to your computer and use it in GitHub Desktop.
WiFi Change Action
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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