Jump to content

macOS 15 Sequoia does not enter sleep mode properly


miliuco
 Share

2 posts in this topic

Recommended Posts

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

Eventosprogramados.png.776b75fc81d6947d18654b98a762a94a.png


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

Startupitems.thumb.png.c45c3f2eefcf985c892bb6cf55609511.png

 

 

Edited by miliuco
Fix typo
  • Like 3
  • Thanks 1
Link to comment
Share on other sites

@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

 

 

 :plane:

 

 

 

Credits by @sysclhttps://github.com/syscl/Fix-usb-sleep/blob/master/fixUSB.sh 

 

 

Link to comment
Share on other sites

 Share

×
×
  • Create New...