How to Run a Script When Your Mac Powers On
Learn how run a script when your Mac powers on or wakes up with Power Manager. This recipe can be expanded to schedule AppleScripts and Automator workflows.
Being able to run a script each time your Mac powers on is surprisingly useful. With a short script, Automator workflow, or AppleScript you can perform repetitive set-up tasks that help make sure your Mac is ready for productive work.
Power Manager lets you trigger events when your Mac wakes up or powers on.
As an example, let’s create an event that turns on and off power to the AirPort interface. This little trick can help fix numerous wireless problems.
Create a Power On Event
Launch Power Manager.
Create an empty event.
Open the event in the event editor.
Add a Power On trigger.
Add a Run Script > Shell Script action.
Edit the Run Script step by clicking on the Cog icon.
Copy and paste in your script:
#!/bin/sh # Turn off Airport on en0 ifconfig en0 down # Turn on Airport on en0 ifconfig en0 up
Change the Short User Name to root to provide the privileges needed to change your Mac’s wireless state.
Apply the Run Script changes.
Save the event changes.
Your new power on event is ready and will be performed when your Mac next powers on or wakes up.
You can change the event name either in the event editor, or directly from the list of events. To change the event name, select the event and press Enter.