-
Notifications
You must be signed in to change notification settings - Fork 19
Description
Sometimes after waking up my M1 MacBook Pro with a monitor always connected, my laptop goes back to sleep a couple seconds after waking and unlocking. I then have to unlock again.
I added some logs and it seems to be hitting
Line 18 in c0985c3
| pmset sleepnow |
Maybe there's a way to track time since last wake and if it's less than ~10 seconds then ignore it? I can also try logging more values to help find a way to differentiate/find the root cause if there's any more useful context I can gather.
One idea of a cause is that ioreg -r -k AppleClamshellState | grep AppleClamshellState | grep Yes takes ~25ms and all the pmset commands take ~750ms, so if the script runs during sleep, sees the lid is closed and then during the 750ms of pmset -g powerstate | grep AppleDisplay | grep USEABLE (or maybe even the following commands, I'm not sure what DCPDPDeviceProxy and DCPDPServiceProxy represent) running the lid is opened and the system wakes up, it looks like the lid is closed and the system is awake, so we go to sleep.