Search code examples
shelllaunchdlaunchdagent

Run plist on wake


I've been searching all over and found options at launchd site. Is there a way to launch a .plist on machine wake? If this is not possible is there a way to run a shell script without installing another package and just use plain shell?


Solution

  • At first it didn't work on my OSX Sierra mac. After restarting my machine the plist configuration seems to work now.

    <key>RunAtLoad</key>
    <true/>
    

    This key makes sure that your plist runs at wake and if you want to specify which script it will run you can do so by

    <dict>
        <key>PathState</key>
        <dict>
            <key>/path/to/your/shell/script.sh</key>
            <true/>
        </dict>
    </dict>