1

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?

Medevin
  • 405
  • 1
  • 5
  • 9
  • 1
    This might help, previous answer doesn't address wake: https://apple.stackexchange.com/questions/27036/possible-to-run-scripts-on-sleep-and-wake – favoretti Oct 10 '17 at 09:38

2 Answers2

1

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.

Iceberg
  • 2,744
  • 19
  • 19
0

Maybe this will help you out:

Running script upon login mac [closed]

Lifely
  • 1,035
  • 12
  • 22