Skip to content

Keep the idle monitor subscribed while stay-awake is on - #12603

Closed
z23 wants to merge 2 commits into
omacom:quattrofrom
z23:fix/idle-monitor-rearm
Closed

z23 wants to merge 2 commits into
omacom:quattrofrom
z23:fix/idle-monitor-rearm

Conversation

@z23

@z23 z23 commented Sep 20, 2026

Copy link
Copy Markdown

Fixes #12302.

Turning stay-awake off (omarchy toggle idle allow-idle) did not re-arm screensaver or lock if the shell had started with stay-awake already on. omarchy-shell idle status then reported enabled:true while the compositor never sent another idle event.

IdleMonitor.enabled was bound to idleEnabled. That property is false until the stay-awake state file is read, and stays false for the whole session when the file is present. Quickshell's IdleMonitor only creates the ext-idle-notify-v1 notification from enabled; a monitor that begins disabled does not re-subscribe when enabled later becomes true.

Stay-awake still cancels idle cycles and handleIdleChanged still ignores events while stay-awake is on. The compositor subscription now stays up so disabling stay-awake can re-arm without restarting the shell.

IdleMonitor.enabled was bound to idleEnabled, so a shell that started
with stay-awake already on never subscribed to ext-idle-notify-v1. Turning
stay-awake off then left screensaver and lock dead until a shell restart.
Stay-awake still cancels idle cycles; the compositor notification stays up
so disabling stay-awake can re-arm.
@llstrk

llstrk commented Sep 21, 2026

Copy link
Copy Markdown

Custom idle timeouts can leave automatic screensaver and lock inactive

Reviewed d3cb1b77 with Quickshell 0.3.1 and Qt 6.11.2.

The always-enabled monitor is created before its effective timeout is known

The initialization order in the reproduced runs was:

Create service before configuration
  -> subscribe with fallback timeout (150s)
  -> customized timings arrive
  -> replace notification (same native address reused)
  -> Quickshell receives idled
  -> service stays idle:false despite enabled:true
  -> no idle cycle or screensaver/lock calls

Removing the enabled binding exposes this early subscription. The observed address reuse is runtime-dependent; the comparison below isolates the creation order.

Custom configuration: screensaver 2s, lock 5s
Production service-creation order; both deadlines elapsed

                           Native idled    Screensaver / lock calls
Baseline                   Received        Both
PR                         Received        Neither
PR, final config supplied
at creation (diagnostic)    Received        Both

That matrix used the unchanged service and a private synthetic Wayland server. Separate actual-shell tests on nested Hyprland reproduced the lost idle propagation with a five-second screensaver timeout; baseline rearmed normally.

Impact: automatic locking can silently stop under this initialization/runtime combination. Address reuse is allocator-dependent, so this is not a claim that every customized installation fails.

Suggested change: initialize the monitor only when the effective initial configuration is resolved, and handle subsequent timeout changes without losing idle-state propagation. Supplying a non-null shell reference alone is insufficient if its configuration still changes asynchronously. Add a behavioral test using the production creation order and nondefault deadlines.

Verified: continuous observation and stay-awake action suppression work when configuration is settled before subscription. The supplied tests pass, but their source-text check misses this interaction.

Original report: baseline successfully resubscribed here, so the stated never-resubscribe diagnosis was not independently reproduced. Runtime timeout edits also expose the underlying Quickshell problem on baseline; that pre-existing case is distinct from the new startup exposure.


Review information

Test scope: real Quickshell and nested Hyprland, plus an isolated native-protocol matrix. Screensaver/lock/wake commands were recorded substitutes; no actual lock authentication, suspend or DPMS tested.

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Automated AI review: Astra inspected source and ran supplied tests; independent Fable 5.1 and Astra reviewers performed runtime investigations. Both final reports, supporting evidence and subsequent qualifications were read before synthesis.

The always-on monitor was created against the builtin 150s timeout, then
replaced when shell.json loaded. That replacement can drop idled, so a
custom screensaver timeout never arms. Wait until both shell config files
have loaded, create the notification at that timeout, and on a later change
disable the monitor before writing the new timeout.
@z23

z23 commented Sep 23, 2026

Copy link
Copy Markdown
Author

The startup finding is right. shellConfig is the builtin 150s/300s object until the default and user shell.json files report, so the always-on monitor subscribed at 150s and then replaced the notification when the real timeout arrived. A non-null shell is not enough.

Taken:

  • shellConfigLoaded becomes true only after both FileViews have loaded or failed. The idle monitor is created then, with that settled timeout as its initial value.
  • A later timeout change disables the monitor, writes the timeout, and enables it again. Writing timeout on a live notification is the replacement that can reuse the native address and drop idled. Disabling first forces the null-to-object transition.
  • Stay-awake still does not unbind the monitor. It only suppresses cycles, so a shell that starts in stay-awake can re-arm once stay-awake is turned off.

The runtime test follows that creation order with a nondefault deadline (builtin 150, then 1s, and a later change to 2s) and requires idled both times. The service is also checked to stay unsubscribed until shellConfigLoaded, then subscribe at the settled timeout rather than 150.

@llstrk

llstrk commented Sep 23, 2026

Copy link
Copy Markdown

Verified by source inspection: e20b54c9 resolves the startup subscription mechanism in the earlier finding. The idle monitor now waits for both configuration files to finish loading or fail, then receives the effective timeout at creation.

Earlier revision: create monitor at 150s -> load custom timeout -> replace notification
Current revision: wait for configuration -> create monitor at the settled timeout

Later timeout changes disable the subscription before writing the new timeout, then re-enable it. Stay-awake remains an action gate rather than a subscription gate. No new production issue was identified in this scoped source review.

This resolves the specific early-subscription finding, not a claim of runtime validation across compositors.


Review information

Test scope: Pinned startup, timeout-update and stay-awake paths, supplied test source, and relevant Quickshell 0.3.1/Qt 6.11.2 source. No tests or native idle events were executed in this follow-up; actual screensaver, lock, suspend and DPMS behavior remain untested here.

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Automated AI review: Astra Medium inspected source and synthesized fresh independent reviews by Opus 5.5 High and GPT 6 Sol Xhigh, checking both full reports and material supporting source evidence.

@omarchybot omarchybot added the bug Something isn't working label Sep 27, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at e20b54c and run on a stock Omarchy worker VM (x86_64, quickshell 0.3.1, hyprland 0.56.2) with this branch linked as the running shell, idle.screensaver set to 15s, and no input.

The stay-awake bug from #12302 does not reproduce on quattro. I started the shell with the stay-awake file present, ran omarchy-toggle-idle allow-idle, and idle fired 15s later and launched the screensaver, in three runs out of three. Quickshell's source agrees: IdleMonitor::updateNotification() creates the notification whenever enabled becomes true, so nothing stops a monitor that started disabled from subscribing later. On stock Omarchy, keeping the monitor subscribed through stay-awake fixes nothing. It also changes what happens when stay-awake is turned off: a session that was already idle starts an idle cycle straight away, where today the timeout starts again from zero. The report came from omarchy-mac on aarch64 with quickshell-git 0.3.0.r20, so it may be specific to that setup. If so, it needs a reproduction there.

The second commit does fix a real bug. On quattro, changing idle.screensaver from 15 to 20 in a running shell stopped idle events completely (none in the next 40s). On this branch the same change fires 20s after the edit. The cause is in Quickshell. When the timeout changes, it deletes the notification and allocates a replacement, and the replacement can land at the same address. bNotification then looks unchanged, so isIdle stays bound to the deleted object. Disabling first sends the pointer through null, which is why IdleSubscription.qml:80-83 works.

Three other open pull requests fix that same bug, and #9570 is the best of them. #9570 (+36/-1) turns the monitor off for one 150ms tick, and only when the timeout the monitor actually uses changes. That covers both the startup swap from the built-in 150s to shell.json and edits made while the shell is running, and it leaves stay-awake alone. The other three each have a cost:

  • This PR (+395/-11) adds a new subscription component, config-loaded flags in shell.qml and a 190-line runtime test, mostly for the stay-awake change. The timeout fix alone needs a few lines.
  • Re-arm idle monitor when timeouts change in shell.json (#8038) #8086 cancels any running idle cycle and its pending lock whenever either timeout changes, even if the monitor's own timeout stays the same.
  • Rebuild the IdleMonitor instead of retuning it #12731 builds no monitor when the shortest timeout is 0. quattro accepts screensaver: 0, so with that setting neither the screensaver nor the later lock would ever start.

I compared #9570, #8086 and #12731 by reading their diffs against Quickshell's source. Only this branch and quattro were run.

The second opinion came from Codex at medium effort. Without seeing my conclusion, it also picked #9570, explained the same address-reuse mechanism, and found the zero-timeout problem in #12731, which I confirmed against IdleModel.secondsFromConfig. It found no defect in how this branch handles the timeout change.

This now waits on the maintainer, who decides which of the four lands. If it turns out to be this one, the smallest version would keep only the disable-then-retime change.

@omarchybot

Copy link
Copy Markdown
Collaborator

Thank you for this, @z23. #9570 fixes the same problem in a way the review judged better, so this is closed in favour of it. If it does not cover your case, please say so there.

Closed at the maintainer's request. The review comment above has the details; it was done by Claude Opus 5.5 with Codex Medium as a second opinion, whose agreement is not independent.

@omarchybot omarchybot closed this Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Idle monitor never re-arms after stay-awake is turned off: no screensaver or idle lock until the shell is restarted

3 participants