aymen
notes

6 november 2026 · 4 min · macos

A two second wake is long enough to start a post

My social media scheduler started a post during one of macOS's brief dark wakes, froze when the laptop went back to sleep, and taught me to ask the Mac whether it is really awake.

Fleet is the tool I built to run my social accounts. Claude drafts the posts, I approve the exact text, and a plain Playwright script with no model in the loop posts it. Approval stores a SHA-256 hash of every part's text and media, and the poster refuses if anything changed. A launchd job runs fleet tick every five minutes and posts whatever is due.

On Thursday 5 November I had five packages scheduled across the evening. Three went out. One failed, and one went out almost three hours late. Neither was a bug in the posting code.

What the logs said

The failed one, a Pip post about macros, was due at 20:00. The tick log says it started at 20:37:20 and failed at 20:45:42 with "couldn't tell whether the X profile is logged in". The screenshot from that attempt is a white page with a loading spinner. X never loaded.

The macOS power log explained it. At 19:55 my MacBook entered "Clamshell Sleep" on battery. I had closed the lid and fallen asleep. After that it never fully woke. It did what Macs do on battery with the lid shut: brief maintenance wakes, called dark wakes, with no display and a few seconds each. One of them was at 20:37:20, and the log gives its length as 2 seconds.

That was enough. launchd ran the missed tick, the tick found a due package, and headless Chrome started opening X. Then the Mac went back to sleep with the whole run frozen inside it. The next wake was at 20:45:42, the same second the run gave up.

The other casualty was a Botworthy post due at 21:00. The Mac slept on, and at 23:46 the tick dutifully posted it, 167 minutes late. That was working as designed: my catch-up limit was 12 hours. In practice a post that goes out near midnight instead of at 9 pm is just a worse post.

Asking the Mac if it is awake

The fix is to have the tick check, before anything else, whether the Mac is properly awake. macOS exposes this in the IOPMrootDomain registry entry. Its "System Capabilities" value is a bit field, and the graphics bit is set only in a full wake, even with the display off. In a dark wake it is missing.

const out = execFileSync('ioreg', ['-r', '-d1', '-c', 'IOPMrootDomain'], { encoding: 'utf8' });
const caps = Number(/"System Capabilities" = (\d+)/.exec(out)?.[1]);
if ((caps & 2) === 0) return 'dark wake'; // no graphics: asleep, waking briefly

I also treat a closed lid as asleep when AppleClamshellCausesSleep is Yes, because that Mac is about to sleep. With an external display on power the flag goes to No, and posting carries on. On my Mac, fully awake, the value reads 15: CPU, graphics, audio and network.

When the check fails, the tick does nothing and logs why. The package stays scheduled and goes out on the first tick after a real wake. The windows where Fleet looks for posts to reply to got the same guard.

The other half

The second change was a single number. The default catch-up window went from 720 minutes to 120. Past that, a missed post goes to "needs attention" with a notification, and I decide whether to reschedule it or post it by hand.

That night I decided by hand. Just after midnight I told Claude to post the macros package, and all six parts went out on X and LinkedIn, each one checked on the page.

A scheduler on a laptop is not a server. "Every five minutes" really means every five minutes the machine is awake, and a Mac has more ways of being half awake than I had assumed.