Reputation: 445
Want to change Wi-Fi settings on wake (osx).
I have script for that but don't want to run it manually every time.
Is there any way to run it on wake?
Upvotes: 1
Views: 3711
Reputation: 3332
This functionality of running script after waking up can be achieved with the powerful hammerspoon:
function printf(s,...) print(s:format(...)) end
wather = hs.caffeinate.watcher.new(function(eventType)
-- screensDidWake, systemDidWake, screensDidUnlock
if eventType == hs.caffeinate.watcher.systemDidWake then
local output = hs.execute("/bin/echo -n hello", false)
hs.notify.new({title="TestTitle", informativeText=output}):send()
printf("%s, world", output)
end
end)
wather:start()
Put those script to $HOME/.hammerspoon/init.lua
and reload hammerspoon, and you can check the above /bin/echo output in the hammerspoon console.
There are several wake up events, including screensDidWake, systemDidWake, screensDidUnlock. See wather api doc for details.
Upvotes: 1
Reputation: 1065
Maybe this will help you out:
Running script upon login mac [closed]
Upvotes: 0