Repository navigation
Treat idle timeout 0 as disabled, not immediate - #12538
Conversation
idle.screensaver / idle.lock of 0 was included in Math.min(), so IdleMonitor's timeout became 0. Releasing a Wayland idle inhibitor (SDL's default screensaver inhibit) then reported idle immediately and locked the session even when lock had been "disabled" by setting it to 0. Treat 0 as disabled when computing the first idle deadline, do not start the corresponding action, and leave IdleMonitor off when both timeouts are 0. Fixes omacom#10860
Automated AI review
Verified: the change addresses the root cause of #10860. On the base,
One remaining edge case: the new "0 means off" rule applies when an idle cycle starts, but not to a cycle that is already running. Changing timeouts during a running idle cycle can lock early
The first row is new with this PR. The second row behaved the same on the base, but now contradicts the intent stated in this PR: a 0 lock timeout should mean no lock. If both values become 0 during a cycle, Impact: an unexpected immediate lock, but only when Suggested change: fix the lock delay when the cycle starts, and check that the lock is still enabled when the timer fires: // startIdleCycle(), lock branch
else {
lockTimer.interval = root.lockDelaySeconds * 1000
lockTimer.restart()
}
// Timer: static interval instead of the live binding
onTriggered: if (root.idleEnabled && root.idledThisCycle && root.lockEnabled) root.lockSystem("lock-timeout")In a QML test harness, this variant locked at the configured deadline in the first case, did not lock in the second, and normal timed locks still fired. The trade-off is that timing edits made during a cycle take effect from the next cycle. Another option is to cancel and restart the cycle when the timeouts change. A Optional test improvement: the new Documentation: the manual ( Review informationTest scope: Source review of the PR at AI process: Opus 5.5 Medium coordination and synthesis, independent Opus 5.5 Xhigh and GPT 6 Sol Xhigh technical assessments with targeted follow-up questions, Opus 5.5 Medium editorial check. Opt out: To stop receiving these reviews, reply to this comment saying so. |
The timers' intervals are bound to the configured delays, so setting the lock or screensaver to 0 while the screensaver is up turns a pending timer's interval to 0 and it fires at once. Check the action is still enabled when its timer fires. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With 0 meaning off, setting the screensaver to 0 while the screensaver is up moves the first idle deadline to the lock's, which turns the pending lock's bound interval to 0 and locks at once, minutes early. Set each timer's interval when the cycle starts, so a change to shell.json takes effect from the next cycle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Codex Medium <noreply@openai.com>
|
| interval: root.lockDelaySeconds * 1000 | ||
| repeat: false | ||
| onTriggered: if (root.idleEnabled && root.idledThisCycle) root.lockSystem("lock-timeout") | ||
| onTriggered: if (root.idleEnabled && root.idledThisCycle && root.lockEnabled) root.lockSystem("lock-timeout") |
There was a problem hiding this comment.
Re-enabled lock misses deadline
If the lock timeout is set to 0 during an active idle cycle while the screensaver remains enabled, the running one-shot lock timer fires with its new zero interval, and this guard suppresses the lock. Setting the timeout back to a positive value does not restart the timer while the monitor remains idle, so the session stays unlocked until another idle cycle begins. Reschedule the lock when its timeout is re-enabled.
| /id: screensaverTimer[\s\S]*?onTriggered: if \(root\.screensaverEnabled\) root\.launchScreensaver\(\)/.test(serviceSource), | ||
| 'idle does not launch a pending screensaver once its timeout is set to 0' | ||
| ) | ||
| assert( | ||
| /id: lockTimer[\s\S]*?onTriggered: if \([^)]*root\.lockEnabled\) root\.lockSystem\("lock-timeout"\)/.test(serviceSource), | ||
| 'idle does not fire a pending lock once its timeout is set to 0' | ||
| ) |
There was a problem hiding this comment.
Timer behavior remains untested
These assertions match text in Service.qml but never run its timers or idle monitor. They pass even if changing a timeout to 0 and back drops the lock deadline, so they cannot catch a regression in the pending-action behavior they claim to cover. A behavioral test of that transition would make the coverage useful.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
With both at 0 the monitor is disabled and handleIdleChanged returns early, so a cycle already running when shell.json changed never cancels: omarchy-system-wake never runs, and if the screensaver never opened a window nothing else ends it. Cancel it the way turning on stay-awake does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Codex Medium <noreply@openai.com>
| } | ||
|
|
||
| // With both timeouts at 0 the monitor stops reporting, so nothing else would end a running cycle. | ||
| onIdleTimersEnabledChanged: if (!idleTimersEnabled) cancelIdleCycle("idle-timers-disabled") |
There was a problem hiding this comment.
Disabled screensaver stays visible
When both timeouts are set to 0 while the screensaver is visible, this handler cancels the idle cycle but does not close the screensaver. cancelIdleCycle runs omarchy-system-wake, which restores brightness without closing the screensaver terminal. The disabled screensaver therefore remains on screen until the user dismisses it with input.
|
Reviewed and verified at 3cebdc3. This fixes #10860 and also #7178, which is now linked. What ran, on a disposable Omarchy worker running Hyprland and the shell from each tree:
Pushed to your branch, three commits:
Second opinion: Codex Medium reviewed each round. It found the early lock and the uncleared cycle above, and its last round on 3cebdc3 found nothing. It can read this session's working notes, so its independence is not guaranteed. Greptile's notes on this head:
#9170 also changes what a 0 timeout does, but keeps 0 as "fire immediately", so it would not fix #10860. It also conflicts with Nothing is left for the author; this waits on the maintainer. |
quattro's idle-timeout-zero fix (omacom#12538) added its own assertions beside the ones this branch adds to test/shell.d/idle-test.sh; both sets are kept. The cap in secondsFromConfig still covers both Timer intervals, which quattro now sets imperatively from the same delay properties. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Treat idle timeout 0 as disabled, not immediate (cherry picked from commit 7901d7d)
Summary
idle.screensaver/idle.lockto0("disabled") still fed0intoMath.min(), soIdleMonitor's timeout became 0.0as disabled when picking the first idle deadline; don't start that action; leaveIdleMonitoroff if both timeouts are 0.Fixes #10860
Test plan
bash test/shell.d/idle-test.sh(stock fail → patch pass)research/pr-verify/10860.mdon the bughunt machineFixes #7178