Repository navigation
Conversation
The bar clock keeps showing the time the lid closed at for up to a minute after it opens. SystemClock schedules its next tick as the delay to the top of the next minute, and delays are measured on CLOCK_MONOTONIC, which stops while the machine is suspended. A clock with four seconds left to run when the lid closes still has four seconds left when it opens. How long the machine slept makes no difference — an eight-hour suspend and a ten-second one leave the same remainder to burn down. Most of that minute passes behind the lock screen; what is left of it lands on the bar the user unlocks into. An NTP correction after a long time offline steps the clock the same way. Checking the wall clock when a timer fires is the cheaper fix, and it is the one the lock service already makes before blanking a freshly woken screen. It does not transfer here, because SystemClock already does it: setTime and schedule both fall back to the current time when the tick they were waiting for turns out to be stale, which is why the clock rights itself a minute after waking rather than staying wrong. It cannot do better, because that check only runs when the late tick arrives, and waiting for the tick is the bug. So Wallclock runs the check on a schedule of its own — nothing else will raise it, as logind announces a resume on a bus the shell does not speak and a stepped clock announces nothing anywhere — and resync() makes a SystemClock re-read the wall clock and reschedule from now. One timer rather than one per widget is what the singleton is for: every bar instantiates its own clock widget and calendar panel. The calendar panel resyncs too, though only a panel left open across a suspend that crossed midnight can reach it: open() already refreshes. It resyncs rather than refreshing because refresh() calls goToToday(), and waking the machine is no reason to drag a calendar left open on another month back to this one. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016DKT4jSou6grTnSjV46BJv
Resolves the conflict in docs/omarchy-shell.md by keeping both the new Wall-clock jumps section and quattro's Elsewhen section. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Reviewed and tested on a worker built from the Omarchy ISO. The fix works; what it waits on is the maintainer choosing between several open fixes for this bug, and a second opinion that could not run today. Merge conflict resolved. This branch conflicted with Reproduced, then fixed. On the worker I stepped the wall clock forward two hours, five seconds into a minute. That uses the same mechanism as a resume:
An actual suspend could not be exercised: the QEMU worker did not wake from Tests. Competing fixes. Several open pull requests fix the same bug, #13504:
This one is the oldest. Choosing between them is the maintainer's decision. Second opinion: did not run. Codex Medium answered a ping, but its daily review quota was spent before it could review this pull request. Nothing here has been checked by a second model. The classification also could not be re-confirmed after the merge commit, so the issue link and the |
|
| function resync(clock) { | ||
| clock.enabled = false | ||
| clock.enabled = true | ||
| } |
There was a problem hiding this comment.
If a third-party plugin pauses its SystemClock with enabled: false and connects it to Wallclock.jumped as documented, resync() turns it back on after a clock jump. The paused clock then resumes ticking and sending updates when its owner expects it to stay stopped.
| function resync(clock) { | |
| clock.enabled = false | |
| clock.enabled = true | |
| } | |
| function resync(clock) { | |
| if (!clock.enabled) return | |
| clock.enabled = false | |
| clock.enabled = true | |
| } |
Knowledge Base Used: Shell UI and desktop interactions
Close a laptop lid and open it again, and the bar clock still reads the time the lid closed at.
datein a terminal is correct the whole time.It does correct itself — but not for up to a full minute, and most of that minute passes behind the lock screen, so what you actually see is a stale clock on the bar you unlock into.
Cause
SystemClockcomputes the delay to the top of the next minute from wall-clock time and arms aQTimerwith that relative delay (schedule()). Relative Qt timers are measured onCLOCK_MONOTONIC, which does not advance while the machine is suspended.So a clock with four seconds left to run when the lid closes still has four seconds left when it opens. How long the machine slept makes no difference — an eight-hour suspend and a ten-second one leave the same remainder to burn down. On the machine this was found on,
CLOCK_BOOTTIME - CLOCK_MONOTONIChad reached 36.4 hours over a single boot: that is how much scheduling time every timer in the shell had lost.An NTP correction after a long time offline steps the clock the same way and leaves the same gap. (A timezone change does not — it moves the offset, not the epoch — and
omarchy-menu-timezonealready refreshes the clock over IPC when it changes one.)Quickshell has not fixed this upstream: #559 is this exact report, closed as user error, and #107 is open and stale. So the shell has to notice for itself.
Fix
Wallclock, a newqs.Commonssingleton, watches for the step and reports it.Wallclock.resync(clock)makes aSystemClockre-read the wall clock and reschedule from now — togglingenabledis the only lever the type exposes for that.Checking the wall clock when a timer fires is the cheaper move, and it is the one
plugins/lock/Service.qmlalready makes before blanking a freshly woken screen: a countdown that spanned a suspend is discarded and re-armed, for no extra wakeups at all. That pattern does not transfer here, and the reason is worth stating plainly —SystemClockalready implements it.setTimeandscheduleboth fall back to the current time when the tick they were waiting for turns out to be more than 500ms stale, and that is exactly why the clock rights itself a minute after waking rather than staying wrong forever. It cannot do better, because the check only runs when the late tick finally arrives, and waiting for that tick is the whole bug.So the check has to run on a schedule of its own. Nothing else will raise it: logind announces a resume on the system bus, but the shell has no D-Bus of its own, and a clock stepped by NTP announces nothing anywhere. The cost is one 1 Hz timer doing two subtractions and a compare — and one, not one per widget: each bar instantiates its own clock widget and calendar panel, which is what the singleton is for. It is also symmetric, unlike the lock service's one-sided check, so a clock stepped backwards is caught too.
Resyncing on unlock instead would be free and would cover the lid-close case, since the lock surface covers the bar for most of the stale minute. It was rejected because it cannot help a clock drawn on the lock screen itself — third-party lock clocks exist — and it misses both suspends that never locked and steps that happen while the session is in use.
The calendar panel resyncs too, though only a panel left open across a suspend that crossed midnight can reach it —
open()already refreshes. It resyncs rather than refreshing becauserefresh()callsgoToToday(), and waking the machine is no reason to drag a calendar left open on another month back to this one.Third-party plugins that display a time have the same problem and can hook the same signal;
docs/omarchy-shell.mdsays how.Testing
./test/shellpasses.test/shell.d/clock-test.shgains six Node assertions covering the detection predicate itself (on-time tick, tick running late under load, either side of the threshold, an eight-hour gap, a clock stepped backwards) plus wiring assertions, including one that pins the panel to resyncing rather than refreshing.SystemClockkeeps painting the pre-suspend time, no step is reported while time passes normally, a step is reported exactly once, and the label lands on the real wall-clock time.