Repository navigation
Conversation
The countdown redrew every second for the whole session, also with every display asleep, where nobody can see it. The spec's event table already says the redraw costs one wake per second while active and visible, but only a closed lid stopped it. With the display set to sleep after a few idle minutes, that is most of a session spent away from the Mac. A DisplaySleepObserver, alive as long as the app, passes NSWorkspace's screensDidSleep and screensDidWake to the session manager. While the displays sleep the 1 Hz timer is off. A wake redraws at once and starts it again, unless the lid keeps it stopped. A lid open starts it as before, without waiting for the wake: opening the lid wakes the displays.
|
Real-Mac report for Build. A clean checkout of that commit, no other pull requests applied, installed with Mac. Lid open, the built-in display only, on battery (99 to 100%). Times are UTC; Checks.
insomnia.log, 20:49 to 21:17:30ZThe measuring scripts' outputpmset samples every 5 s during the first session (SleepDisabled, Battery Power powermode)pmset -g log, display on/offNot run.
|
… sleep The observer only heard of later changes, and the state started as awake. An app opened again while the displays slept, by a relaunch over SSH or after a force quit, resumed its session with the countdown redrawing until the next display event. The observer now reads the displays once when it starts, every online one asleep (CGDisplayIsAsleep), and reports that before the launch reconcile, so a resumed session starts with the redraw off.
|
Thank you for this. Your head commit 4a9bdb1 is merged unchanged into #145, together with five other menu bar pull requests that change the same files. When #145 merges, GitHub marks this pull request as merged too, with your commits and your authorship. Please don't push to this branch from now on. A new commit wouldn't be in #145, so this pull request would stay open instead of showing as merged. If you want to change something, comment here and I'll add it to #145. #145's description lists the conflicts resolved in its merge commits and the two maintainer fixes after them. 🤖 Generated with Claude Code |
The status item runs its own 1 Hz tick for the projected countdown while a start is in flight. #137 stopped the manager's redraw while every display sleeps but not this one. The manager's displaysAsleep is now observable; the status item stops its tick while it is true and redraws the projection when a display wakes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Lands #99 at e738536, by 0xRafie. Conflict with #137 and the maintainer's time change fix, resolved here: each added an app-lifetime object to InsomniaApp, the display sleep and time change observers and #99's session command watcher. All three are kept. The observers start first; the watcher starts after the launch reconcile, as in #99.
What changes
The menu bar countdown redraws every second for the whole session, also when every display is asleep and nobody can see it. The spec's event table already says the redraw costs one wake per second "while active and visible", but only a closed lid stopped it. With the display set to sleep after a few idle minutes, most of a session spent away from the Mac is spent with the screen off.
The countdown now stops while the displays sleep:
DisplaySleepObserver, alive as long as the app, passes NSWorkspace'sscreensDidSleepandscreensDidWaketo the session manager. Nothing runs between the two. It also reads the displays once at launch, so a session resumed while they sleep starts with the redraw off.On my Mac (M5 Pro, macOS 27.0.1, lid closed on an external display with #135) the redraw cost about 0.33% of a core with the display asleep: 0.19 to 0.21 s of CPU a minute over five one-minute windows, about what it costs with the display on. With this change, three such minutes cost 0.03 s, 0 s and 0 s (lid open, built-in display; details in the real-Mac report). Small per minute, but it ran for as long as the session did.
With #135, a MacBook closed on an external display runs its countdown, so this also covers that monitor going to sleep.
How it was tested
DisplaySleepTests: a display sleep stops the redraw and a wake redraws at once with the right time; a wake with the lid closed leaves it stopped; a lid open with the displays asleep redraws at once; a session started, or resumed at launch, while the displays sleep starts redrawing at the wake; a wake with no session arms nothing; the observer reports the state at launch, then turns the two workspace notifications into the calls.-warnings-as-errors.Real-Mac evidence
In a comment for the head commit.


Confidence Score: 5/5
The PR appears safe to merge, with the previous startup issue fixed and no new actionable issues found.Summary
Stops the menu bar countdown redraw while displays sleep and redraws immediately on wake.
Reviews (2) · Last reviewed commit: "Menu bar: from Greptile's review, read a..." · Reviewed by Greptile