Browse Source

Hammerspoon: fix DNS auto switch rule

ubuntu_ci
Ein Verne 4 years ago
parent
commit
7ffcc9ad8b
No known key found for this signature in database
GPG Key ID: 926634D64ACAD792
  1. 4
      hammerspoon/init.lua

4
hammerspoon/init.lua

@ -157,10 +157,10 @@ hs.network.reachability.forAddress(homeDNS):setCallback(function(self, flags)
-- note that because having an internet connection at all will show the remote network -- note that because having an internet connection at all will show the remote network
-- as "reachable", we instead look at whether or not our specific address is "local" instead -- as "reachable", we instead look at whether or not our specific address is "local" instead
local networkConf = hs.network.configuration.open() local networkConf = hs.network.configuration.open()
if (flags & hs.network.reachability.flags.reachable) > 0 and currentLocation ~= homeLocationUUID then if (flags & hs.network.reachability.flags.reachable) > 0 and currentLocation == homeLocationUUID then
hs.alert.show("switch to Home network location") hs.alert.show("switch to Home network location")
networkConf:setLocation("Home") networkConf:setLocation("Home")
elseif (flags & hs.network.reachability.flags.reachable) == 0 and currentLocation == homeLocationUUID then elseif (flags & hs.network.reachability.flags.reachable) == 0 and currentLocation ~= homeLocationUUID then
hs.alert.show("switch back to Automatic network location") hs.alert.show("switch back to Automatic network location")
networkConf:setLocation("Automatic") networkConf:setLocation("Automatic")
end end

Loading…
Cancel
Save