Created
July 31, 2017 08:16
-
-
Save rvdm/9e21e76ced4b0b4af5744bdf0d13dfd2 to your computer and use it in GitHub Desktop.
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 wifiWatcher = nil | |
local homeSSID = "trustedhomewifi" | |
local lastSSID = hs.wifi.currentNetwork() | |
function ssidChangedCallback() | |
newSSID = hs.wifi.currentNetwork() | |
networkconfig = hs.network.configuration.open() | |
if newSSID == homeSSID and lastSSID ~= homeSSID then | |
-- joined home wifi | |
networkconfig:setLocation("Automatic") | |
hs.alert.show("Welcome home!") | |
elseif newSSID ~= homeSSID and lastSSID == homeSSID then | |
-- departed home wifi | |
networkconfig:setLocation("sshvpn") | |
hs.alert.show("Danger, Will Robinson!") | |
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
.. obviously easily adjusted to support multiple SSIDs etc.