Keep a pending idle action on its deadline when the timings change
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>
This commit is contained in:
1 parent
377b15be4b
commit
3839d0b4e0
2 files changed
+20
-4
No files matched your search
@@ -94,14 +94,22 @@ Item {
|
||||
root.screensaverStartedThisCycle = false
|
||||
resetScreensaverWindows()
|
||||
|
||||
// Set this cycle's deadlines once: a bound interval would restart a pending
|
||||
// timer from the moment shell.json changes, locking early or late.
|
||||
if (root.screensaverEnabled) {
|
||||
if (root.screensaverDelaySeconds === 0) launchScreensaver()
|
||||
else screensaverTimer.restart()
|
||||
else {
|
||||
screensaverTimer.interval = root.screensaverDelaySeconds * 1000
|
||||
screensaverTimer.restart()
|
||||
}
|
||||
}
|
||||
|
||||
if (root.lockEnabled) {
|
||||
if (root.lockDelaySeconds === 0) lockSystem("lock-timeout-immediate")
|
||||
else lockTimer.restart()
|
||||
else {
|
||||
lockTimer.interval = root.lockDelaySeconds * 1000
|
||||
lockTimer.restart()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,14 +273,12 @@ Item {
|
||||
|
||||
Timer {
|
||||
id: screensaverTimer
|
||||
interval: root.screensaverDelaySeconds * 1000
|
||||
repeat: false
|
||||
onTriggered: if (root.screensaverEnabled) root.launchScreensaver()
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: lockTimer
|
||||
interval: root.lockDelaySeconds * 1000
|
||||
repeat: false
|
||||
onTriggered: if (root.idleEnabled && root.idledThisCycle && root.lockEnabled) root.lockSystem("lock-timeout")
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user