Create bootscript.sh
:
#!/bin/bash
# make sure to run this program as root and make it run at boot
ps -ef | grep UserEventAgent | grep -v grep | awk '{print $2}'| sudo xargs kill sleep 15
ps -ef | grep UserEventAgent | grep -v grep | awk '{print $2}'| sudo xargs kill sleep 15
ps -ef | grep UserEventAgent | grep -v grep | awk '{print $2}'| sudo xargs kill sleep 15
Make plist: and save it as:
sleepfix.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.fix.sleep</string>
<key>ProgramArguments</key>
<array>
<string>/bin/bash</string>
<string>/PATH/bootscript.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>UserName</key>
<string>root</string>
</dict>
</plist>
Make sure it runs:
sudo cp sleepfix.plist /Library/LaunchDaemons
sudo launchctl load -w /Library/LaunchDaemons/sleepfix.plist