miliuco Posted Monday at 09:48 AM Share Posted Monday at 09:48 AM (edited) My system (Z390 Aorus Elite + i9-9900K + RX 6600 XT) running macOS 15 Sequoia doesn't always go to sleep as expected. Sometimes it does, turning off lights and fans, but other times it stays awake, even with the screen on. This happens with the same settings I use on macOS 14 Sonoma and macOS 13 Ventura where the system goes to sleep normally. There are 2 situations that can cause this behavior: apsd process (Apple Push Notification Services Daemon): when active, sleep usually fails. This process seems to be related to notifications from various applications and services. It can be stopped with one of these commands: sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.apsd.plist sudo launchctl bootout -w /System/Library/LaunchDaemons/com.apple.apsd.plist System Information >> Power >> Wake Events: sleep usually fails when there are Scheduled Events that can be generated by different processes com.apple.alarm dependent (they are Wake Type). These events can be deleted with the command sudo pmset schedule cancelall Spoiler If there are no Scheduled Events and the apsd process is stopped, sleep works fine. The launchd process macOS uses launchd to manage daemons and agents (tasks, processes or resident programs that run in the background without user interaction), and you can use it to run shell scripts. You cannot interact with launchd directly; you must use the launchctl command to start and stop daemons and agents. During boot, launchd is the first process that the kernel runs. Here are the places where macOS stores the configuration files for these background processes: /System/Library/LaunchDaemons: System daemons installed by Apple, protected folder /System/Library/LaunchAgents: Agents installed by Apple, protected folder /Library/LaunchDaemons: System daemons added by other applications /Library/LaunchAgents: Agents added by other applications ~/Library/LaunchAgents: Agents added by other applications that apply only to the logged in user. It is possible to create launchctl controlled tasks with plist files located in the /Library/LaunchAgents, /Library/LaunchDaemons or ~/Library/LaunchAgents folders. One important difference is that tasks existing in /Library/LaunchDaemons can be run as root but those in the LaunchAgents folders are run as the logged in user. I have created a task that is launched every so often by running the 2 commands mentioned above (clear scheduled events and stop apsd). Since both commands require sudo, the plist file has to be placed in /Library/LaunchDaemons. The following is a guide on how I did it. There is a lot of information about this on the Internet, I will limit myself to describing my personal experience as it applies to sleep mode on macOS Sequoia. Creating the files Create a shell script and save it as nosched.sh: #!/bin/zsh sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.apsd.plist sudo pmset schedule cancelall Copy it to /usr/local/bin: sudo cp /Users/yo/Desktop/LaunchDaemons/nosched.sh /usr/local/bin Make root the owner of the file: sudo chown root:wheel /usr/local/bin/nosched.sh Create a plist file and save it as com.user.nosched.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.user.nosched</string> <key>ProgramArguments</key> <array> <string>/usr/local/bin/nosched.sh</string> </array> <key>RunAtLoad</key> <true/> <key>StartInterval</key> <integer>300</integer> <key>KeepAlive</key> <true/> </dict> </plist> In this file we have: Label: label that must match the file name without the .plist extension ProgramArguments: the command or file to be executed RunAtLoad: activate from boot StartInterval: time interval in seconds between executions KeepAlive: keep alive. Copy it to /Library/LaunchDaemons. It has already been mentioned that the plist files in the /Library/LaunchDaemons folder can be executed as root but those in the /Library/LaunchAgents folder are executed as the active user. sudo cp /Users/yo/Desktop/LaunchDaemons/com.user.nosched.plist /Library/LaunchDaemons Make root the owner of the file: sudo chown root:wheel /Library/LaunchDaemons/com.user.nosched.plist Regarding the apsd process, /System/Library/LaunchDaemons/com.apple.apsd.plist already exists but the /System folder is protected and macOS does not allow to modify it or act on it, so in order to stop apsd it is necessary to run SIP (partially) disabled. You can use the SIP settings required by OCLP root-patch, csr-active-config=03080000 (0x803 in Clover) in OpenCore's config.plist. This setting returns Unknown state when running csrutil status in Terminal and the security variables it disables are: CSR_ALLOW_UNTRUSTED_KEXTS - 0x1 (1) CSR_ALLOW_UNRESTRICTED_FS - 0x2 (2) CSR_ALLOW_UNAUTHENTICATED_ROOT - 0x800 (2,048). Starting the task After rebooting with the relaxed SIP value, the apsd process stops interfering with sleep. Regarding scheduled events, you can start the task to run in the background with one of these commands (in my case both seem to work well): sudo launchctl load /Library/LaunchDaemons/com.user.nosched.plist sudo launchctl start /Library/LaunchDaemons/com.user.nosched.plist If running load gives you this error: Load failed: 5: Input/output error Try running launchctl bootstrap as root for richer errors. Use bootstrap to get detailed information about the reason for the error: sudo launchctl bootstrap /Library/LaunchDaemons/com.user.nosched.plist To see if the process is running: sudo launchctl list | grep com.user.nosched # com.user.nosched must be present - 0 com.user.nosched To see if apsd is no longer active: sudo launchctl list | grep com.apple.apsd # the command returns nothing if com.apple.apsd is stopped You can now configure Power Saver with the pmset command. Example: sudo pmset displaysleep 1;sudo pmset disksleep 2;sudo pmset sleep 6 The shell script appears in Startup Items (System Settings >> General). Spoiler Edited Monday at 10:17 AM by miliuco Fix typo 4 1 Link to comment Share on other sites More sharing options...
Max.1974 Posted Monday at 04:34 PM Share Posted Monday at 04:34 PM @miliuco Hello great master Emílio, as always, your posts are very detailed and helpful. Greatly passionate about Hackintosh and eager to help people. I got a bash script from the internet that helped me a lot, and I put it in an Xcode script to make it easier, it solved a lot about sleep in my Hacks and especially in Sequoia. If you want to add to your knowledge, and I believe you already know, but it installs the sleep watcher and fixes the sleep return, of course you need to be up to date with the other PRW, GPRW, UPRW parameters. So, here is the script that helps a lot. Just Double Click on kext blue icon. Thanks. USBFIX_SLEEP.zip Credits by @syscl: https://github.com/syscl/Fix-usb-sleep/blob/master/fixUSB.sh 2 Link to comment Share on other sites More sharing options...
miliuco Posted Monday at 06:44 PM Author Share Posted Monday at 06:44 PM @Max.1974 Dear friend, I was already looking at this script a few days ago when you first uploaded it. It is interesting because, from a single script, it creates the configuration plist file for launchd and performs the actions that we would normally do by hand. But I lack the knowledge (or dedication) to create a script like this that does what I mention in my post. Anyway, thanks and I will study it again to see if I am able to do something like this for sleep in Sequoia. 1 1 Link to comment Share on other sites More sharing options...
naiclub Posted Monday at 06:55 PM Share Posted Monday at 06:55 PM @miliuco Hello, I use USBWakeFixup.kext and it works very well. I got it from Master Maldol. I sleep soundly and wake up immediately when I wake up. 2 Link to comment Share on other sites More sharing options...
Max.1974 Posted Monday at 09:04 PM Share Posted Monday at 09:04 PM 2 horas atrás, miliuco disse: @Max.1974 Caro amigo, eu já estava olhando para este roteiro há alguns dias, quando você o carregou pela primeira vez. É interessante porque, a partir de um único script, ele cria o arquivo de configuração plist para o launchd e executa as ações que normalmente faríamos manualmente. Mas me falta o conhecimento (ou dedicação) para criar um roteiro como este que faça o que menciono no meu post. De qualquer forma, obrigado e vou estudá-lo novamente para ver se sou capaz de fazer algo assim para dormir em Sequoia. Hi my @Miliuco dear sorry if i uploaded before, my mind after 50 years its not the same hehehe!! Enjoy it and if you need some help about scripting, we have many practices and free solutions with some "blank" bash script, just insert in and save. 1 1 Link to comment Share on other sites More sharing options...
miliuco Posted Monday at 09:20 PM Author Share Posted Monday at 09:20 PM @naiclub Thanks. I know about USBWakeFixup, I used it in the past with my previous hack that didn't wake up with a single keyboard or mouse tap and needed 2 taps. But this problem is different and it's not fixed with this kext. I have it with Sequoia. Ventura and Sonoma all work fine. But on Sequoia sleep is erratic, sometimes yes and sometimes no. With the trick I posted, Sequoia goes to sleep properly. I'm still looking for unwanted side effects just in case there are any, to discuss them here. 2 Link to comment Share on other sites More sharing options...
Recommended Posts