Skip to content

Instantly share code, notes, and snippets.

@bruvv
Last active August 9, 2020 15:38
Show Gist options
  • Save bruvv/dba4c4182c83fa80d6a2c746695b55e0 to your computer and use it in GitHub Desktop.
Save bruvv/dba4c4182c83fa80d6a2c746695b55e0 to your computer and use it in GitHub Desktop.
Fix iMac with fusion drives not sleeping

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment