Skip to content

Instantly share code, notes, and snippets.

@abrookins abrookins/init.lua
Last active Mar 30, 2017

Embed
What would you like to do?
Restart fastkit with Hammerspoon when DNS changes
local network = hs.network.configuration.open()
local fastkitPath = '~/.rbenv/shims/fastkit'
local home = '/Users/andrew'
function fastkitCompleted(exitCode, stdOut, stdErr)
if exitCode ~= 0 then
hs.alert.show("Fastkit failed to reload")
log.d(stdOut)
end
end
function fastkitCallback(store, keys)
job = hs.task.new(fastkitPath, fastkitCompleted, {'restart', 'proxy'})
job:setEnvironment({PATH='$PATH:/bin:/usr/bin:/usr/local/bin:/sbin', HOME=home})
job:setWorkingDirectory('~/src/fastkit')
job:start()
end
network:monitorKeys('State:/Network/Global/DNS')
network:setCallback(fastkitCallback)
network:start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.