Skip to content

Add independent lock-on-idle and screen-off switches to the idle service - #6538

Closed
acidkill wants to merge 12 commits into
omacom:quattrofrom
acidkill:feat/idle-lock-toggle
Closed

acidkill wants to merge 12 commits into
omacom:quattrofrom
acidkill:feat/idle-lock-toggle

Conversation

@acidkill

@acidkill acidkill commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #6086, which @dhh closed because it "edits Hypridle and the old
menu" and Quattro idle timing "now belongs to the native shell service and
shell configuration." This rebuilds the same idea directly against that
native service: shell/plugins/services/idle/Service.qml and
~/.config/omarchy/shell.json's idle key, no Hypridle involved.

Along the way, testing turned up a real gap beyond the original PR's scope:
there was no way to get the screensaver and/or a plain screen-off without
the automatic lock. Someone in a private, lockable room may want the
displays to sleep on idle (power saving, burn-in prevention) without a
password prompt every time they glance back at the screen. This PR adds
that as a third, fully independent axis alongside the screensaver and the
lock, plus a small terminal UI (omarchy-config-idle, reachable from
Setup → Config → Idle) to configure all three.

What changes

  • Lock-on-idle switch (idle.lockOnIdle, defaults true): gates only
    the automatic lock fired by the idle timeout. Explicit locking --
    the menu's Lock entry, SUPER+CTRL+L, lid close, pre-suspend locking --
    is untouched and always locks regardless of this setting.
  • Screen-off switch (idle.screenOffOnIdle / idle.screenOff,
    defaults false / 600): blanks the displays and keyboard backlight on
    idle, independent of both the screensaver and the lock. When lock-on-idle
    is enabled and its timeout is at or before the screen-off timeout, locking
    already blanks the screen -- the TUI's "On idle" summary reports that as
    happening with the lock rather than double-listing the same moment.
  • The scheduling math that picks the shared first idle deadline and each
    action's delay moved into a pure, unit-tested function
    (IdleModel.idleSchedule()) instead of living only as inline QML
    bindings exercised solely by hand.
  • omarchy-brightness-keyboard off is now idempotent -- two blanks can land
    back to back in one idle period (the lock's own blank, and now the idle
    service's), and brightnessctl only keeps one saved slot per device.
  • Both the lock screen and the idle service now blank the displays through
    one shared command, omarchy-system-blank, instead of each carrying its
    own copy of the same two calls.

Commits

  1. Make keyboard-backlight off idempotent
  2. Add omarchy-system-blank and route the lock screen's blanking through it
  3. Add an independent lock-on-idle switch to the idle service
  4. Add a screens-off axis to the idle service, independent of the screensaver and lock

Test plan

  • test/shell.d/idle-test.sh, test/shell.d/system-blank-test.sh,
    test/shell.d/brightness-keyboard-test.sh, test/shell.d/bin-style-test.sh
    all pass
  • Live-verified on a real Quattro session via omarchy dev link: screensaver
    shows with lock-on-idle off and no lock prompt on wake; screens blank at
    the configured timeout with lock-on-idle and screensaver both off, and a
    single keypress wakes them with no password prompt; explicit
    SUPER+CTRL+L still locks unconditionally regardless of the switch
  • Screenshot of the new Setup → Config → Idle screen
image

Toni Nowak added 4 commits August 3, 2026 18:39
brightnessctl keeps a single saved slot per device, so calling omarchy-brightness-keyboard off twice without an intervening restore overwrites the saved brightness with 0 -- the second blank has nothing left to restore to. Two blanks can already land in one session: the lock screen's own blanking and, from here on, the idle service's. Skip the save when the backlight is already off.
Blanking the displays was a private one-liner inside the lock service's
Process. The idle service is about to need the exact same two calls in the
exact same order, so give it a name instead of a second copy: bin's own
convention for a small, focused, testable command.
The idle service always locked at the end of the idle cycle -- the only
override was Stay Awake, which suspends the screensaver too. Some people want
the screensaver on but never want a password prompt on wake: a private,
lockable home office is enough security on its own.

lockOnIdle defaults to true, so nothing changes for anyone who doesn't touch
it. Explicit locking (the menu entry, SUPER+CTRL+L, lid close, pre-suspend
locking) is untouched -- this only gates the automatic lock the idle timeout
fires. The delay math moves into IdleModel.idleSchedule() so it stays
covered by plain Node assertions instead of only being exercised live.

This restores the intent of omacom#6086, closed because it targeted the retired
Hypridle architecture -- rebuilt here against the Quickshell-based idle
service that replaced it.

Thanks to @dhh for the original review.
…saver and lock

A real gap surfaced in live testing: someone who wants zero password prompt
on wake (a private, lockable home office is its own security) but still
wants the displays to sleep on idle -- to save power and avoid burn-in --
had no way to say so. Turning locking off left the screens on forever;
turning locking on brought the password prompt back.

IdleModel.idleSchedule() takes a third, independently-nullable timeout.
Locking still takes priority when both are configured to fire around the
same time: lockSystem() owns the display from that point, so a screen-off
timer surviving into it would blank the screen while the user is mid-way
through typing their unlock password, uncancellably. screen-off itself only
touches DPMS/backlight state, so it does not claim the screensaver's window
surface the way locking does -- the screensaver keeps firing on its own
schedule independently, even while the display is dark.

omarchy-config-idle gains its own on/off switch and timeout for this, and
the "On idle" summary line spells out when screen-off is subsumed by an
already-armed lock at or before its own deadline, rather than double-listing
the same moment as two separate events.
Copilot AI balanced review requested due to automatic review settings August 3, 2026 16:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds independent screensaver, lock-on-idle, and screen-off configuration to the native idle service.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Changes:

  • Adds idle scheduling and configuration switches with a new TUI.
  • Centralizes display blanking and makes keyboard blanking idempotent.
  • Adds shell tests for scheduling and blanking behavior.

Reviewed changes

Copilot reviewed 9 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
bin/omarchy-brightness-keyboard Adds idempotent backlight blanking.
bin/omarchy-config-idle Adds the idle configuration TUI.
bin/omarchy-system-blank Centralizes display and keyboard blanking.
config/omarchy/shell.json Adds shipped idle defaults.
default/omarchy/omarchy-menu.jsonc Exposes idle configuration in Setup.
shell/plugins/lock/Service.qml Uses the shared blank command.
shell/plugins/services/idle/IdleModel.js Implements idle scheduling math.
shell/plugins/services/idle/Service.qml Adds independent idle actions.
shell/shell.qml Adds built-in idle defaults.
test/shell.d/brightness-keyboard-test.sh Tests duplicate keyboard blanks.
test/shell.d/idle-test.sh Tests schedules and configuration defaults.
test/shell.d/system-blank-test.sh Tests shared blank-command ordering.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread shell/plugins/services/idle/Service.qml Resolved
Blanking and waking are launched as separate async bash processes with no
ordering between them. If activity lands right after screen-off starts but
before its omarchy-system-blank finishes, firing the wake immediately races
it -- whichever process exits last wins, so the blank can complete after the
wake and leave the displays dark even though the idle cycle was just
canceled.

wakeScreens() now checks whether screenOffProcess is still running and, if
so, defers the wake instead of firing it concurrently; screenOffProcess's
own onExited fires the deferred wake once the blank has genuinely finished.

Thanks @Copilot for catching this on the previous commit.
Copilot AI review requested due to automatic review settings August 3, 2026 16:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 12 changed files in this pull request and generated no new comments.

Suppressed comments (2)

shell/plugins/services/idle/Service.qml:375

  • screenOffTimeoutSeconds accepts zero (and the new model explicitly clamps zero to one second), but this re-arm timer bypasses that clamp. After activity wakes a blanked display, a configured screenOff: 0 therefore fires again immediately, so the user cannot keep the display awake. Apply the same one-second minimum to this timer.
    interval: root.screenOffTimeoutSeconds * 1000

shell/plugins/services/idle/Service.qml:368

  • This can blank while idleMonitor.isIdle is already false. For example, with screensaver=300 and screenOff=400, mapping the screensaver at 300 can emit the active transition retained by handleActiveSignal; this timer then blanks at 400, but mouse activity cannot produce another isIdleChanged until the monitor first becomes idle again at 600, so the display may not wake. Ensure blanking only occurs from a state where subsequent activity is observable, or track activity independently of the monitor's boolean transition.
    onTriggered: if (root.screenOffOnIdle && root.idleEnabled && root.idledThisCycle) root.turnOffScreens("screen-off-timeout")

Toni Nowak added 2 commits August 11, 2026 13:20
idleSchedule() already clamps a configured zero timeout to one second so
ext-idle-notify never gets handed a timeout that means "report idle
immediately," but screenOffRearmTimer's interval sits outside that shared
math -- it binds directly to the raw screenOffTimeoutSeconds. A screenOff: 0
in shell.json therefore made the rearm timer fire on essentially every event
loop tick: the display blanks again the instant it wakes, with no way to
keep it on.

screenOffRearmSeconds applies the same one-second minimum locally.

Thanks @Copilot for flagging this in the suppressed review comments.
ext-idle-notify only reports "resumed" as a transition out of the idle
state, and the screensaver's launch activity can spend the main
monitor's one transition before a later blank. Real input after that
blank then goes unseen until the main monitor re-enters idle -- with
screensaver=300 and screenOff=400, mouse movement at 450 leaves the
displays dark for up to another two and a half minutes. Keyboard input
usually escapes through a different door (the screensaver exits on a
keypress and the window-close event cancels the cycle), which is
exactly why only the mouse appeared broken.

A second monitor runs only while the screens are off. The user is by
definition idle then, so a one-second timeout re-arms it almost
immediately, and its own resumed edge routes through the existing
handleActiveSignal decision: relight and re-arm when the screensaver
cycle stands, cancel outright otherwise. Inhibitors are ignored -- only
raw input should wake a blanked display.

Thanks @Copilot for flagging this in the suppressed review comments.
Copilot AI review requested due to automatic review settings August 11, 2026 11:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 12 changed files in this pull request and generated no new comments.

Suppressed comments (3)

shell/plugins/services/idle/Service.qml:476

  • The deferred wake is cleared even when runProcess() refuses to launch it because wakeProcess is still running. This is reachable with the supported one-second rearm interval: a new blank can run while the previous wake is still restoring displays, and activity during that blank sets this flag; if blank exits first, the required final wake is dropped and the screen can remain dark. Keep the request pending when launch fails and retry it from wakeProcess.onExited.
      if (root.wakeAfterBlankPending) {
        root.wakeAfterBlankPending = false
        root.runProcess(wakeProcess, "wake", "omarchy-system-wake")

shell/plugins/services/idle/Service.qml:150

  • A blank process can still be running here when screen-off and lock share a deadline: startIdleCycle() starts screenOffProcess first, then immediately calls lockSystem(). Clearing screenOffThisCycle does not stop that process, and the lock service's wake path is not serialized with it, so quick activity can wake the lock screen before the old blank finishes and the late blank leaves it dark. Avoid launching the redundant screen-off action when locking subsumes that deadline, or transfer/await the in-flight process before handing display ownership to the lock service.
    // The lock service owns the displays from here, so this cycle's blank is no
    // longer ours to report or re-arm.
    root.screenOffThisCycle = false
    resetScreensaverWindows()
    runProcess(lockProcess, "lock", "omarchy-system-lock")

test/shell.d/system-blank-test.sh:27

  • This test only exercises a successful keyboard-backlight command, so it does not cover the helper's defining fallback: display blanking must continue when a machine has no keyboard backlight and the first command fails. Run the helper with the keyboard mock returning nonzero and retain the display assertion.
CALL_LOG="$call_log" PATH="$mock_bin:$ROOT/bin:$PATH" "$ROOT/bin/omarchy-system-blank"

…er the no-backlight blank path

A wake could still be silently dropped: flushPendingWake() cleared
wakeAfterBlankPending as soon as it tried to launch wakeProcess, even
when runProcess() refused because wakeProcess was already busy
finishing an earlier wake -- reachable with the one-second rearm floor.
The flag is now only cleared once the launch actually succeeds, and
both screenOffProcess and wakeProcess retry it from onExited.

startIdleCycle() started screenOffProcess before calling lockSystem()
when screen-off and lock shared a deadline. Clearing screenOffThisCycle
didn't stop that process, and the lock service's own wake path isn't
serialized with it, so quick activity could wake the lock screen before
the old blank finished and the late blank left it dark.
screenOffSubsumedByLock skips screen-off everywhere it can fire once
the lock is due at or before the same deadline; lockSystem() also
disowns any wake already left pending by a blank that outlives it, for
the same race when screen-off legitimately precedes the lock instead of
sharing its deadline.

Added the test system-blank-test.sh was missing: omarchy-system-blank
has no set -e, so it already continued to the display step when a
machine without a keyboard backlight fails the first one -- this pins
that down instead of leaving it only implied by the script's own
comment.

Thanks @Copilot for all three.
Copilot AI review requested due to automatic review settings August 11, 2026 11:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 12 changed files in this pull request and generated no new comments.

Suppressed comments (1)

shell/plugins/services/idle/Service.qml:169

  • Clearing these flags does not stop or await an in-flight screenOffProcess, which the preceding comment explicitly says can survive into locking. The lock service can independently run omarchy-system-wake as soon as the user interacts; if that wake finishes before the old idle blank, the old process disables DPMS afterward and leaves the unlock screen dark. Serialize the handoff by delaying lock ownership until the idle blank exits, or use a shared blank/wake serializer across both services.
    root.screenOffThisCycle = false
    root.wakeAfterBlankPending = false

The lock service starts its own, independent wake as soon as the user
interacts, with no way to know a screen-off blank from here can still
be running -- lockSystem() cleared its own bookkeeping but never
touched the actual screenOffProcess. If that independent wake finished
before the stale blank did, the blank disabling DPMS afterward left the
unlock screen dark.

lockSystem() now waits for an in-flight blank to actually exit before
handing display ownership to the lock service, instead of racing it:
the reason is stashed in pendingLockReason and the real lock only fires
from screenOffProcess's own exit. This only delays idle-timeout-driven
locking (lockTimer, or the immediate branch in startIdleCycle()) by
however long the blank takes to finish, typically well under a second
-- explicit locking (SUPER+CTRL+L, the menu entry) goes straight to
omarchy-shell lock lock and never reaches this function.

cancelIdleCycle() also disowns a pending lock: it's still just a
decision at that point, not a running process, so activity or Stay
Awake during the defer window cancels it like every other piece of
cycle state instead of locking anyway once the blank happens to finish.

Thanks @Copilot for catching this.
Copilot AI review requested due to automatic review settings August 11, 2026 13:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 12 changed files in this pull request and generated no new comments.

Suppressed comments (3)

shell/plugins/services/idle/Service.qml:113

  • turnOffScreens() still permits the opposite race: it can launch a blank while wakeProcess is running, and if screenOffProcess is already running, runProcess() drops the new blank after screenOffThisCycle was set. This is reachable through the one-second rearm path: the previous wake can finish after the reblank (leaving the displays on), or a deferred wake can undo a skipped reblank with no timer left to retry it. Queue the blank until both processes are idle instead of racing or dropping it.
  function turnOffScreens(reason) {
    logEvent("screen-off", reason || "requested")
    root.screenOffThisCycle = true
    runProcess(screenOffProcess, "screen-off", "omarchy-system-blank")

shell/plugins/services/idle/Service.qml:422

  • This monitor starts only when the displays are blanked, so it cannot emit a resumed edge until it has first spent one second becoming idle. When screensaver activity has already consumed the main monitor's resumed edge, a mouse movement during that first second is missed and the displays remain dark until a second input. Arm this watcher for the entire idle cycle (while retaining the existing screenOffThisCycle handler guard) so it is already idle when a delayed blank occurs.
    enabled: root.idleEnabled && root.screenOffThisCycle
    timeout: 1

shell/plugins/services/idle/Service.qml:480

  • This handler updates only lockTimer, although changing lock-on-idle also changes screenOffSubsumedByLock and may leave a deferred lock behind. Disabling lock mid-cycle can therefore leave screen-off unarmed when it was previously subsumed, while pendingLockReason still launches a lock from screenOffProcess.onExited; enabling lock can likewise leave an obsolete screen-off timer running. Resynchronize the dependent screen-off timer and clear any deferred automatic lock when disabling.
  onLockOnIdleChanged: syncSwitchTimer(root.lockOnIdle, lockTimer, root.lockDelaySeconds)

Toni Nowak added 3 commits August 11, 2026 16:17
…resync what lock-on-idle decides

Three holes, all the same shape: state here saying one thing while the
processes and monitors it stands for were doing another.

turnOffScreens() only had half a serializer. A wake requested during a
blank was queued, but a blank requested during a wake was launched into
the race, and a blank requested during another blank was dropped
outright after screenOffThisCycle had already been set -- so the service
believed the screens were dark while the surviving wake left them lit,
with every timer spent. Both directions now record one wanted display
state, newest request wins, cleared only once its process really
started; both process exits drain it. Wanting the screens on and then
off is not a queue to work through, so the newest intent is the whole
answer, and neither process can overlap the other any more.

The dark-screen watcher was armed at the blank, but with a one-second
timeout it needs a second of quiet before it has a resumed edge to give
-- and it was spending that second with the screens already dark,
missing exactly the first input it exists to catch. It now runs for the
whole cycle, with its handler still gated on the screens actually being
off, so it is already idle when a delayed blank lands. Its guard now
re-checks every term of its own binding: both cycle-ending paths drop
idledThisCycle before this cycle's screen-off ownership, so the
disable-reentry would otherwise report input nobody gave.

lockOnIdle decides screenOffSubsumedByLock as well as lockTimer, so its
handler resyncs the screen-off it just re-decided -- turning the lock
off un-subsumes a screen-off this cycle skipped, turning it on leaves
one armed the lock now covers. Dropping the deferred lock that switch
can leave behind now goes through one helper shared with
cancelIdleCycle, because dropping it also has to hand the displays
back: lockSystem() disowned them expecting that lock to arrive, and
cancelIdleCycle's own wake is gated on idledThisCycle, which
lockSystem() had already cleared. Without that, Stay Awake pressed
while the screens were going dark left them dark, unlocked, with no
armed cycle to notice.

Thanks @Copilot for all three.
These assertions each check that some function or object contains a
particular line, and they framed that as `rg -A<n>` -- a guess at how
many lines the block happens to be today. The guess silently stops
covering the thing the assertion names as soon as the block grows: the
lockSystem checks were already reaching for -A32, and adding one line to
cancelIdleCycle pushed its own subject out of the window, failing an
assertion about code that was still perfectly correct.

qml_block prints one block by its opening line, up to its own closing
brace, so each assertion is scoped to what it is actually talking about
and stays that way.
…kened

The screensaver makes the compositor report activity when it maps --
the premise handleActiveSignal is built on, and why it keeps the cycle
armed through that report instead of cancelling it. But screen-off can
be configured to fire ahead of the screensaver, and then that report
lands on panels this service darkened moments earlier. The branch that
exists to absorb self-inflicted activity was also waking the displays
for it: with screensaver=300 and screenOff=150, the screens went dark
at 150s and lit themselves back up at 300s, staying lit for a full
rearm period with nobody at the machine.

launchScreensaver() now claims the one report its own mapping provokes
and handleActiveSignal spends it rather than acting on it, so only a
bump that is not the screensaver's own relights the panels. The claim
is released wherever the launch it belongs to is forgotten, so it can
never outlive its cycle and swallow a real bump.
Copilot AI review requested due to automatic review settings August 11, 2026 14:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 12 changed files in this pull request and generated no new comments.

@acidkill

acidkill commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor Author

@dhh hope this version fits much better direction where you see omarchy going. if not - please advice or point how would you see that functionality. in my little own company everyone runs Omarchy (big thanks for this amazing distro), we are using proposed by me functionality daily and I can bet than many would benefit by having not only option to block screensaver and screen lock, but also block only one, but - not loosing option to put monitors (in my case four of them) to sleep - avoiding monitor burnout without distracting screensaver and the need to use password to resume work after couple of minutes worth break with an ebook in your hand. If you would see it as some module like the "Stay Awake" or extending configuration options provided by Monitor control plugin :
image instead of TUI - please let me know :)

@bjarneo

bjarneo commented Sep 21, 2026

Copy link
Copy Markdown
Member

Automated duplication check: this pull request looks similar to #7863, which covers the same idle blank without lock. I keep that one open and close this one to consolidate review.

If you feel this is the wrong decision, please open the PR again with a note on the difference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants