Jump to content

macOS 15 Sequoia does not enter sleep mode properly


miliuco
 Share

27 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:

 

1.- 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

2.- 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

In my case, scheduled events seem to affect sleep more than apsd process. Sleep frequently fails when there are scheduled events but usually works fine without disabling apsd. However, there are comments on this and other forums from users who do not fix this problem until they act on apsd.

Therefore, my recommendation is to cancel scheduled events first, test if the system enters and exits sleep as it should and disable apsd only as a secondary resource if sleep continues to fail. Adding to this, cancellation of scheduled events can be done without modifying the SIP value but disabling apsd forces you to work with SIP partially disabled.

 

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.

 

1.- Cancel scheduled events

 

Create a shell script and save it as nosched.sh:

#!/bin/zsh
sudo pmset schedule cancelall
#sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.apsd.plist

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

2.- Deactivating apsd process

 

Remember to do this only if method 1 is not enough and/or you verify that, with apsd inactive, sleep works fine.

 

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).

The nosched.sh file must be modified to uncomment the command that disables apsd:

#!/bin/zsh
sudo pmset schedule cancelall
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.apsd.plist

3.- Starting the task


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

Regarding apsd, after rebooting (with the relaxed SIP value) the apsd process stops interfering with sleep.

 

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 task is started (com.user.nosched must be present):

sudo launchctl list | grep com.user.nosched
- 0 com.user.nosched

To see if apsd is no longer active (the command returns nothing if com.apple.apsd is stopped)::

sudo launchctl list | grep com.apple.apsd

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
Scheduled events as main
  • Like 7
  • 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 

 

 

  • Like 3
Link to comment
Share on other sites

@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.

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

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. 

  • Like 1
  • Haha 1
Link to comment
Share on other sites

@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.

  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...

I've found that on my system it's enough to cancel scheduled events and I don't need to disable apsd to fix sleep. This has the added advantage that it's not mandatory to relax SIP. But this may be different for other users. In fact, there have been comments on the forum that disabling apsd improves sleep on systems where it doesn't work well.


Modified the first post accordingly.

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

I've had a sleep issues and these are commands that I use to try to "fix" them. Maybe it helps someone.

 

For checking things: 

pmset -g

pmset -g log

pmset -g assertions

pmset -g log | grep sleep | tail -n 1

 

To fix things:

sudo pmset -a autopoweroff 0

sudo pmset -a powernap 0

sudo pmset -a standby 0

sudo pmset -a proximitywake 0

sudo pmset -a tcpkeepalive 0

sudo pmset -a ttyskeepawake 0

sudo pmset -a womp 0

sudo pmset hibernatemode 0

 

If the EFI firmware does not read sleepimage correctly, errors can occur so I use these:

 

sudo rm /var/vm/sleepimage

sudo touch /var/vm/sleepimage

sudo chflags uchg /var/vm/sleepimage

  • Like 3
Link to comment
Share on other sites

on my HP Probook 650 G1  I dont have sleep issue the only thing is I lost Bluetooth after wake up, only in sequoia; thats never happend on any other macos version.

  • Like 3
Link to comment
Share on other sites

@Irish_Man

My settings are the same. No difference. 

Also tried:

  • defaults write com.apple.loginwindow PowerButtonSleepsSystem -bool yes -> macOS goes to sleep when pressing power button
  • defaults write com.apple.loginwindow PowerButtonSleepsSystem -bool no -> macOS displays a dialog (sleep, restart, shutdown) as in real Macs.

It's something happening in Sequoia, in older macOS I haven't had sleep issues for a long time.

 

@chris1111

Yes, I see that there are systems sleeping fine but others don't. Not a long time ago @eSaF and others commented about deactivating apsd to have proper sleep.

  • Like 3
Link to comment
Share on other sites

1 hour ago, miliuco said:

Not a long time ago @eSaF and others commented about deactivating apsd to have proper sleep.

Yes Bro although the script I posted worked perfectly, there was caveat whereas it could affect iMessage function as reported by some.

Hence the reason the script was accompanied by an 'Undo' choice.

 

I  had a problem with Sleep/Wake where the machine would not Sleep and used that script to remedy the problem.

It worked perfectly, but to be honest I did not noticed any problems with iMessage, not to say there wasn't.

 

My Sleep/Wake problem was solved by the following Sequoia Beta Update so I discarded the script.

At this moment Sleep/Wake is working as should on my machine without a problem. Sorry to hear others are having this problem.

 

  • Like 3
Link to comment
Share on other sites

Hi guys, tested the script that I implemented and Works fine too with i5-9600k / Aorus B360-M Gaming 3 / AMD Radeon RX 64 Vega 8Gb 

 

Clover & Opencore 

 

CapturadeTela2024-10-13s17_09_40.png.dab53a6da079d64d7085cb2f9d110e07.png

Spoiler

CapturadeTela2024-10-13s17_13_25.thumb.png.282d186854c451c45f18926f4b820cce.png

 

  • Like 2
Link to comment
Share on other sites

@Max.1974

This script works fine and does what it is supposed to do but it is different from what I have proposed.
Sleepwatcher is a great tool to run commands or tasks when the system goes to sleep and when it wakes up.
I have a different issue, the system does not go to sleep, in this case sleepwatcher is not useful.
But I have the project to use sleepwatcher to disable Bluetooth on sleep and re-enable it on wake up on systems with Wi-Fi and Bluetooth Intel that lose sleep and have instant wake after sleep when using the required extensions for Bluetooth. This happens to me and other users. It is something I will find time to work on. Do you have this issue, instant wake after sleep when using Intel Bluetooth? (I guess this is OT 🤫 ).

Edited by miliuco
Fix typo
  • Like 4
Link to comment
Share on other sites

31 minutes ago, miliuco said:

@Max.1974

This script works fine and does what it is supposed to do but it is different from what I have proposed.
Sleepwatcher is a great tool to run commands or tasks when the system goes to sleep and when it wakes up.
I have a different issue, the system does not go to sleep, in this case sleepwatcher is not useful.
But I have the project to use sleepwatcher to disable Bluetooth on sleep and re-enable it on wake up on systems with Wi-Fi and Bluetooth Intel that lose sleep and have instant wake after sleep when using the required extensions for Bluetooth. This happens to me and other users. It is something I will find time to work on. Do you have this issue, instant wake after sleep when using Intel Bluetooth? (I guess this is OT 🤫 ).

@miliuco create one sleepwatcher for user have issue loosing bluetooth after wake :thumbsup_anim:

  • Like 3
Link to comment
Share on other sites

@eSaF yes, unfortunately I was one of those. When I used the script, sleep was fixed but my iMessage was broken. It took me some time to figure out what went wrong.

 

@miliuco I checked my "System Information >> Power >> Wake Events" and there is always some "Scheduled Event: but it doesnt affect my Sleep/Wake. (Check pics)

 

The issue I have that I can't fix is after wake up. I always get that "Disk Not Ejected Properly" error.  

I mapped my USB ports ( triple checked) and I can't get rid of that error.

 

Spoiler

1.thumb.png.d2f7af6b4d94d8ac1ae43e3f70dcc91c.png2.png.4e37843023fd91c0b331591e0f497388.png

 

  • Like 2
Link to comment
Share on other sites

18 hours ago, chris1111 said:

@miliucocrie um sleepwatcher para o usuário ter problema de perder o bluetooth após o despertar:thumbsup_anim:

 

Hi my masters @Chris1111 and @Miliuco 

 

If someone have been issues to wake Bluetooth after sleep, run this tool installer:

 

Is a tool to install "Home Brew" and Sleep bluetooth tool from brew install "sleepwatcher blueutil"

 

Thanks again @miliuco !! I think I fix that old patcher 

 

Home Brew & SleepBTWatcher installer.zip

 

Sources: 

 

## Install homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
## IMPORTANT: Once the install finishes run the two commands displayed in the terminal window
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> $HOME/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
## Install the bluetooth util and sleepwatcher
brew install sleepwatcher blueutil
## This creates a file which switches bluetooth off when the macbook lid is closed
echo "$(which blueutil) -p 0" > ~/.sleep
## This creates a file which switches on bluetooth when the lid is open
echo "$(which blueutil) -p 1" > ~/.wakeup
## This makes both the files runable
chmod 755 ~/.sleep ~/.wakeup
## Finally restart the sleepwatcher service (to pickup the new files)
brew services restart sleepwatcher

 

And for the ended with Gold Key, run at the final in Terminal: 

 

sudo pkill bluetoothd 

Its for reset your Bluetooth configs 

Good Lucky

 

;)

 

 

 

 

 

 

 

 

 

 

Edited by Max.1974
  • Like 2
Link to comment
Share on other sites

Hi @Irish_Man if you edit correctly your SSDTS and patchers to wake and sleep, for exemple checking your DSDT I think is PCI00 need fix SMBUS and PRW, RTCAWAC, RHUB devices (USB mapping) etc...

 

I make this with my hacks and no more issues.

 

ACPI  Pacthes (you need check what is necessary for your hardware): 

 

CapturadeTela2024-10-13s23_43_53.png.90be420b39253eeb8bf64451773973ef.png

 

ACPI plist patchers

 

1-7

 

CapturadeTela2024-10-13s23_45_39.thumb.png.9bc296ec8cb5e273f1602cee8d8b20a0.png

 

8-13

 

CapturadeTela2024-10-13s23_45_51.thumb.png.5ac68d8c5ad66a6be8644c3e9c6a0293.png

 

To fix issues about RHUB Ports my video detailed 

 

Compile your SSDT-RHUB to better performance USB 3.0 in MacOs and Hackintosh build.

 

Hot Patch Guide from GitHub 

 

https://github.com/jsassu20/OpenCore-HotPatching-Guide 

 

Good Lucky ;) 

 

 

 

 

 

Edited by Max.1974
  • Like 1
Link to comment
Share on other sites

@Max.1974

Excellent! SleepBTWatcher script is a good starting point to me. It has all that I need to try (stop BT on sleep and start on wake, when using Intel BT). Thanks.

 

One thing to mention is that the daemon name blued has been changed in modern macOS to bluetoothd.

So the commands where blued exists must be changed. E.g.

sudo launchctl stop com.apple.blued

Must be

sudo launchctl stop com.apple.bluetoothd

This is the fixed script, it can be saved as SleepBTWatcher.sh, no need of an application:

#!/bin/bash

# Docs I read
# https://gist.github.com/nicolasembleton/afc19940da26716f8e90
# https://gist.github.com/ralph-hm/a65840c4f5e439b90170d735a89a863f
# https://github.com/max-lobur/dotfiles/blob/master/sh/bt.sh

# Things I had to do beforehand
#brew install blueutil
#brew install sleepwatcher
#sudo mkdir -p /usr/local/sbin
#sudo chown -R $(whoami):staff /usr/local/sbin/
#brew link sleepwatcher
#/usr/local/sbin/sleepwatcher --verbose -w ~/.local/bin/restart-bluetooth
#brew services start sleepwatcher

# Stop all the bluetooth stuff
sudo kill -9 $(pgrep bluetoothd)
/usr/local/bin/blueutil -p 0
sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
sudo kextunload -b com.apple.iokit.IOBluetoothHostControllerUARTTransport
sudo launchctl stop com.apple.bluetoothd

# Start enough of the bluetooth stuff
/usr/local/bin/blueutil -p 1
sudo launchctl start com.apple.bluetoothd
sudo kextload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport

Note that the script requires Homebrew.

And I think the scripts ~/.sleep and ~/.wakeup are missing with the commands to be run when entering sleep and when waking up.

 

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

Hi my friend @miliuco thanks to tell us about this issue, I try fix that with new patcher re-uploaded above. 

 

I hope now fix that, and is a home brew installer too. 

 

:thanks_speechbubble: 

 

:wink_anim:

11 minutos atrás, Irish_Man disse:

Dang @Max.1974, thats way above my league😂

Eu assisti ao vídeo e não percebi que não falo português (piada)

Eu costumava saber como “converter” meu usb mapeado kext para acpi, mas esqueci como fiz isso.

 

Hi my friend, post here your "virgin" RHUB and I you tru fix it for you! 

 

:D 

  • Thanks 1
Link to comment
Share on other sites

19 hours ago, miliuco said:

@Max.1974

This script works fine and does what it is supposed to do but it is different from what I have proposed.
Sleepwatcher is a great tool to run commands or tasks when the system goes to sleep and when it wakes up.
I have a different issue, the system does not go to sleep, in this case sleepwatcher is not useful.
But I have the project to use sleepwatcher to disable Bluetooth on sleep and re-enable it on wake up on systems with Wi-Fi and Bluetooth Intel that lose sleep and have instant wake after sleep when using the required extensions for Bluetooth. This happens to me and other users. It is something I will find time to work on. Do you have this issue, instant wake after sleep when using Intel Bluetooth? (I guess this is OT 🤫 ).

 

Hi  @miliuco my dear friend, 

 

Emílio, If you have a wireless Pcie card with USB bluetooth you may be able to map it with the modified RHUB SSDT which I believe is necessary from the z490 cards onwards up to the z790. 

I made a video explaining it.  The tools I implemented work for many who don't have all SSDTs packers like me.  I didn't have the bluetooth intervals issue, this may be due to the fact that I compile my kexts and use Clover, which in terms of power management does not have SMC modules but FakeSMC, but I tested it on Opencore and didn't see differences. In fact, here in Sequoia 15.0.1 I no longer needed these tools, it goes to sleep and wakes up calmly. It was fix for betas.

And a developer friend mine @Hnanoto created two kexts naturally originating from Apple configurations, and I use them well, and they may be responsible for improving bluetooth

I hope it helps my friend, as I don't use any Bluetooth kext or firmware or data for Broadcomns cards, except that I mention, and which in my opinion, BlueToolFixup causes this. So I removed it.

But I know not all of them are native friendly.

I hope I could have helped you.

 

:wink_anim:

 

My kexts that I use

 

Spoiler

CapturadeTela2024-10-14s13_25_09.thumb.png.cb7b10da386e9f364e565c3140709d5a.png

 

 

Try use this two kexts: 

 

AirPortUtility.kext and BluetoothFileExchange.kext

 

AirPortUtility.kext.zip

 

https://github.com/hnanoto/AirPort-Utility/releases/tag/1.0.1 

 

BluetoothFileExchange.kext.zip

 

https://github.com/hnanoto/Bluetooth-File-Exchange/releases/tag/1.0.1

 

By @Hnanoto 

 

Source: 

Edited by Max.1974
  • Like 2
Link to comment
Share on other sites

@Max.1974

"Home Brew & SleepBTWatcher installer script" (seven posts above) is okay, it installs all required things, creates both ~/.sleep (disables BT ) and ~/.wakeup (enables BT) files and at the end kills bluetoothd process to start all the new settings (it is reactivated in a few seconds). I have to try it.


The question I have is if in the files ~/.sleep and ~/.wakeup it will be enough with these single line commands:

  • $(which blueutil) -p 0 (~/.sleep)
  • $(which blueutil) -p 1 (~/.wakeup)

Or if it will be necessary to complete them with more commands as in the other script you have uploaded:

  • ~/.sleep
    sudo kill -9 $(pgrep bluetoothd)
    $(which blueutil) -p 0
    sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
    sudo kextunload -b com.apple.iokit.IOBluetoothHostControllerUARTTransport
    sudo launchctl stop com.apple.bluetoothd
  • ~/.wakeup
    $(which blueutil) -p 1
    sudo launchctl start com.apple.bluetoothd
    sudo kextload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport

I'll try both ways. Did you try both also? hanks.

  • Like 2
Link to comment
Share on other sites

 Share

×
×
  • Create New...