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?
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?
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.