Skip to content

Honor D-Bus idle inhibits on the paths Chromium actually calls - #13359

Closed
HerrStolzier wants to merge 7 commits into
omacom:quattrofrom
HerrStolzier:idle-inhibit-dbus
Closed

HerrStolzier wants to merge 7 commits into
omacom:quattrofrom
HerrStolzier:idle-inhibit-dbus

Conversation

@HerrStolzier

@HerrStolzier HerrStolzier commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #6475.

Quattro replaced hypridle with the Quickshell idle service. hypridle owned org.freedesktop.ScreenSaver; nothing does now, so D-Bus Inhibit() from browsers and players is dropped and the screensaver fires over playing video.

What this does

omarchy-idle-inhibit owns org.freedesktop.ScreenSaver (the same name hypridle owned) and exports the object paths clients actually call:

  • /org/freedesktop/ScreenSaver — Chromium/Chrome power_save_blocker_linux.cc (video / display wake lock)
  • /ScreenSaver — VLC, Firefox/Zen

org.freedesktop.PowerManagement is left unowned. Chromium uses that name for audio, downloads, and WebRTC; owning it would pin the screensaver and lock for background music. Chromium skips an unowned PowerManagement name, so video still inhibits via ScreenSaver.

Inhibitors are ref-counted, reaped when the caller leaves the bus, and published as JSON under $XDG_RUNTIME_DIR/omarchy/idle-inhibit/state (pid-signed so a crashed daemon cannot pin idle off). The idle service creates that directory before watching it (so a daemon that starts after the shell is still observed), folds the count into idleEnabled, and derives idle toggle from the stay-awake flag.

A user unit starts the daemon with the session. First-run enables it separately from the other units so a missing packaged unit cannot fail sleep-lock/fcitx. The migration enables it for existing Quattro installs and falls back to a checkout symlink when the packaged unit has not landed yet.

Why not #6572

#6572 only exports /ScreenSaver. On Omarchy 4.0.4-1, Chromium 152 and Chrome 153 call /org/freedesktop/ScreenSaver; that path returns UnknownMethod against #6572. #8452 covered both ScreenSaver paths plus PowerManagement and was closed as a duplicate of #6572.

This is a fresh branch on current quattro.

Test

  • test/shell.d/idle-inhibit-test.sh — debug rendering, probe liveness (exited-child pid), private-bus Inhibit/UnInhibit/disconnect on both ScreenSaver paths, PowerManagement stays unowned, QML wiring, first-run enable isolation
  • test/shell.d/idle-test.sh — IdleModel parse/cancel/rearm
  • Live on this box (Ryzen 9 5950X, RX 6800, 4.0.4-1): daemon from the checkout owns ScreenSaver on the Chromium path; PowerManagement stays unowned.

Packaging note: bin/* is already globbed into the omarchy package; the user unit needs an install -Dm644 line in omarchy-settings (config-test.sh asserts that mapping). omacom/omarchy-pkgs#210 already adds it. First-run and the migration keep sessions working until that lands.

Quattro dropped hypridle's org.freedesktop.ScreenSaver owner, so browser
video cannot inhibit the screensaver. Export both ScreenSaver object paths
plus PowerManagement.Inhibit, reap disconnected callers, and fold the
published count into the idle service.
@llstrk

llstrk commented Sep 27, 2026

Copy link
Copy Markdown

Automated AI review

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

Verified: at the D-Bus level the daemon does what the description says. It answers Inhibit/UnInhibit on /org/freedesktop/ScreenSaver, /ScreenSaver and /org/freedesktop/PowerManagement/Inhibit, drops a caller's cookies when it leaves the bus, and publishes an empty state on SIGTERM. The new tests fail when the Chromium path, UnInhibit, disconnect reaping or the PowerManagement object is reverted. The idle toggle change is needed and correct. Three issues look worth settling: PowerManagement inhibits also block the lock, the shell's state watcher can miss the daemon until the shell restarts, and the unit depends on a packaging change.

PowerManagement inhibits block the screensaver and the automatic lock

Every PowerManagement Inhibit goes through the same handle_inhibit and count as ScreenSaver (bin/omarchy-idle-inhibit), and the shell folds count into idleEnabled. In Chromium 152, the two interfaces carry different wake-lock types (power_save_blocker_linux.cc, split since Chromium commit 50b7869d):

Chromium wake lock                       D-Bus name                        Counted
"Video Wake Lock" (playing video      -> org.freedesktop.ScreenSaver       yes
  on a visible page)
"Playing audio" (any recently audible -> org.freedesktop.PowerManagement   yes
  tab, including background tabs)
"Download in progress"                -> org.freedesktop.PowerManagement   yes
WebRTC active PeerConnections         -> org.freedesktop.PowerManagement   yes

In an isolated run on a private bus, a PowerManagement Inhibit("chromium", "Playing audio") produced count: 1, which the shell's parser turns into idleEnabled = false.

Impact: music playing in any Chromium tab or web app, a long download, or an open WebRTC call keeps the screensaver and the automatic lock from firing. This goes beyond restoring hypridle, which owned only org.freedesktop.ScreenSaver, and the idle section of the manual describes it as "about locking and the screensaver, not power". The test "PowerManagement Inhibit persists" currently pins this behaviour.

Suggested change: do not count PowerManagement cookies toward the idle count. Either stop owning org.freedesktop.PowerManagement (Chromium skips a PowerManagement service with no owner), or keep answering it but leave it out of count, and change the test to assert that a PowerManagement hold does not disable idle. Chromium's video lock uses the ScreenSaver path, so video inhibits from Chromium are unaffected.

The state watcher is armed once, on a directory that may not exist yet

Service.qml watches $XDG_RUNTIME_DIR/omarchy/idle-inhibit with a FileView. In Quickshell v0.3.1, FileView adds a watch for that path and its parent only when the path is set, and re-arms only on a path change or reload(). Qt's inotify watcher silently drops paths that do not exist. Nothing else in Omarchy creates $XDG_RUNTIME_DIR/omarchy; the daemon creates it on its first publish.

idle service loads          -> watch $RT/omarchy/idle-inhibit  (missing, dropped)
                               watch $RT/omarchy               (missing, dropped)
daemon starts, publishes    -> creates $RT/omarchy/idle-inhibit/state
Chromium plays video        -> state count: 1
shell                       -> no event, dbusInhibitorCount stays 0, lock fires

This is based on Quickshell and Qt source plus a syscall-level replica of the watch setup: with $RT/omarchy missing, no events arrived even after an Inhibit made count: 1; with $RT/omarchy present, the watch picked up the new directory.

Impact: when the idle service loads before the daemon's first publish, D-Bus inhibits are ignored until the shell restarts, which is the original #6475 behaviour, while omarchy debug idle shows the inhibitor because it reads the file directly. From the install and migration scripts, this applies to the first session after a fresh install (first-run normally starts the unit after the shell is already up) and to migrations applied without a shell restart (the login notifier or a bare omarchy-migrate). On other logins nothing orders the shell against the daemon; which one usually wins was not measured.

Suggested change: create the directory before arming and then call reload(), as the stay-awake watcher in the same file does.

The user unit needs the omarchy-settings install line

omarchy-settings does not yet install omarchy-idle-inhibit.service to /usr/lib/systemd/user/, and the PR's own config-test.sh fails on exactly that mapping. Fresh installs get all migrations pre-marked, so there only enable-user-units.sh enables the unit, and it passes all eight units to a single systemctl --user enable --now.

Impact: systemd checks every unit name before enabling any (checked with systemd 261 systemctl --root: one missing unit gives exit 1 and zero units enabled). Without the packaged unit, a fresh install would leave all eight units unenabled, including omarchy-sleep-lock.service, and first-run would retry at every login.

Suggested change: land this together with the omarchy-settings and omarchy-settings-dev install line. The open omacom/omarchy-pkgs#210 (written for #8452, same unit filename) already adds exactly that line to both recipes.

Smaller notes

  • Optional test improvement: the "dead pid" case writes {"pid":1,...} and relies on kill -0 1 failing. That holds for a normal user but not as root or where pid 1 is the same user's process (as under bubblewrap). There the test fails, and because fail exits, every D-Bus scenario after it is skipped. Using the pid of a child that has already exited (for example $(bash -c 'echo $$')) keeps the intent; with that change the full file passed.
  • If org.freedesktop.PowerManagement is already owned, the daemon exits and leaves org.freedesktop.ScreenSaver unowned too. This goes away if PowerManagement is no longer owned; otherwise the two names could be served independently.
  • The pid check only helps when something re-runs the probe. If the daemon dies with holders and stays down (for example after hitting the restart limit), idle stays suppressed until the shell restarts. omarchy debug idle also prints those stale holders as active, since it does not apply the probe's pid check.
  • Open Keep the screensaver off while Firefox-family browsers play media #8955 changes the same idleEnabled expression and its test asserts that exact text, as this PR's test does for its own. If both land, the two gates need to be combined and both tests updated.

Review information

Test scope: source review of all changed files, the idle service and the install, migration and first-run paths, plus Quickshell v0.3.1, Qt, systemd, Chromium 152, VLC, Firefox and hypridle source. Isolated runs (the daemon cases on private D-Bus buses) covered the daemon, the probe, the PR tests with mutation checks, the migration with a stubbed systemctl, and offline systemctl --root enable behaviour. Quickshell, a browser, a live session and a real systemd user manager were not run; the watcher issue rests on source and a syscall-level replica.

AI process: Opus 5.5 Medium coordination and synthesis, Opus 5.5 Xhigh technical review and final fact check, GPT 6 Sol Xhigh search for related issues, Opus 5.5 Medium editorial check.

Opt out: To stop receiving these reviews, reply to this comment saying so.

PowerManagement Inhibit is Chromium's audio/download/WebRTC lock, not
video. Leave that name unowned so background tabs cannot pin the
screensaver. Create the runtime state directory before FileView watches
it, and enable the user unit outside the first-run batch so a missing
packaged file cannot fail sleep-lock.
@HerrStolzier

Copy link
Copy Markdown
Contributor Author

The three items from the community review are in 606bd45:

  • org.freedesktop.PowerManagement is left unowned, so Chromium audio/downloads/WebRTC cannot pin screensaver or lock. Video still goes through /org/freedesktop/ScreenSaver.
  • The idle service mkdirs $XDG_RUNTIME_DIR/omarchy/idle-inhibit and FileView.reload()s before watching, same pattern as stay-awake.
  • First-run enables this unit on its own (with a checkout symlink if the packaged unit is missing), so a missing name cannot fail the sleep-lock/fcitx batch.

The dead-pid probe case now uses an exited child instead of pid 1. Happy to adjust further.

@llstrk

llstrk commented Sep 29, 2026

Copy link
Copy Markdown

Automated AI review

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

Outcome: At 606bd454 new first-run code breaks owe-integration-test.sh without OMARCHY_PATH. Earlier review status:

owe-integration-test.sh now needs OMARCHY_PATH

enable-user-units.sh runs under set -u and now reads $OMARCHY_PATH; the test sets only HOME and PATH. Without OMARCHY_PATH exported (e.g. a clean sandbox) it fails with unbound variable; it passed at 45cadff4. With it set, the fallback link can land in $XDG_CONFIG_HOME, outside the test home.

Suggested change: pass XDG_CONFIG_HOME="$work/home/.config" OMARCHY_PATH="$ROOT" at owe-integration-test.sh:56.

Reproducer (fails at 606bd45)

test/shell.d/owe-integration-test.sh runs install/user/first-run/enable-user-units.sh with only HOME and PATH overridden. The script runs under set -u, and 606bd45 adds a reference to $OMARCHY_PATH (line 29), so the test now depends on the caller's environment.

Run from a checkout of the PR head (606bd45), with OMARCHY_PATH not set:

$ cd /tmp/omarchy && env -u OMARCHY_PATH -u XDG_CONFIG_HOME bash test/shell.d/owe-integration-test.sh | tail -2
/tmp/omarchy/install/user/first-run/enable-user-units.sh: line 29: OMARCHY_PATH: unbound variable
Enable OWE desktop video backgrounds and lock feed
ok - a failed live service start fails the migration
[exit status: 1]

The same command at the previously reviewed head (45cadff):

$ cd /tmp/omarchy && env -u OMARCHY_PATH -u XDG_CONFIG_HOME bash test/shell.d/owe-integration-test.sh | tail -2
ok - lock posters are cached, refreshed after source changes, and old frames are evicted
ok - failed poster generation never publishes a partial image
[exit status: 0]

With OMARCHY_PATH set and XDG_CONFIG_HOME pointing outside the test's temporary HOME, the test passes but the first-run fallback writes its unit symlink into that directory (no packaged /usr/lib/systemd/user/omarchy-idle-inhibit.service on the machine):

$ cd /tmp/omarchy && OMARCHY_PATH=/tmp/omarchy XDG_CONFIG_HOME=/tmp/xdg-demo bash test/shell.d/owe-integration-test.sh | tail -1; find /tmp/xdg-demo -type l -printf '%p -> %l\n'
ok - failed poster generation never publishes a partial image
/tmp/xdg-demo/systemd/user/omarchy-idle-inhibit.service -> /tmp/omarchy/default/systemd/user/omarchy-idle-inhibit.service
[exit status: 0]

Suggested test change (following docs/testing.md, "Fake $HOME, real $OMARCHY_PATH"):

 : >"$TEST_CALLS"
-HOME="$work/home" PATH="$work/bin:$PATH" bash "$ROOT/install/user/first-run/enable-user-units.sh"
+HOME="$work/home" XDG_CONFIG_HOME="$work/home/.config" OMARCHY_PATH="$ROOT" PATH="$work/bin:$PATH" bash "$ROOT/install/user/first-run/enable-user-units.sh"
 grep -E '^systemctl --user enable --now .*owed.service' "$TEST_CALLS" >/dev/null

With that change, at 606bd45:

$ cd /tmp/omarchy && env -u OMARCHY_PATH -u XDG_CONFIG_HOME bash test/shell.d/owe-integration-test.sh | tail -1
ok - failed poster generation never publishes a partial image
[exit status: 0]

$ cd /tmp/omarchy && XDG_CONFIG_HOME=/tmp/xdg-demo bash test/shell.d/owe-integration-test.sh | tail -1; find /tmp/xdg-demo -type l | wc -l
ok - failed poster generation never publishes a partial image
0
[exit status: 0]

([exit status: N] is the exit status of the whole pipeline, run with pipefail.)

Earlier findings in detail
  • PowerManagement counted toward idle: resolved. Only org.freedesktop.ScreenSaver is owned now. In Chromium 152 power_save_blocker_linux.cc, an unowned PowerManagement name is skipped with no fallback to ScreenSaver, and video wake locks still go to ScreenSaver. On a private bus, a PowerManagement Inhibit gets ServiceUnknown and a ScreenSaver Inhibit returns a cookie. The new test fails when the name is owned again.
  • Watcher armed on a missing directory: resolved. Quickshell v0.3.1 reload() re-creates the watch on the path and its parent, and fileChanged comes only from watcher events, so the reload in onExited cannot loop. In a syscall-level replica of the FileView and Qt watch setup (not Quickshell itself), the "shell first" order sees the held inhibit at 606bd454 and missed it at 45cadff4.
  • Unit in the first-run batch: resolved. With a stubbed systemctl, the batch no longer names the unit, and the unit is enabled separately (linked first when the packaged unit is missing). On packaged installs the link target is omarchy-settings' copy under /usr/share/omarchy/default/.
  • Packaging line: still present. config-test.sh fails against omarchy-pkgs master with PKGBUILD does not explicitly install default/systemd/user/omarchy-idle-inhibit.service, and passes with the fix: check for iwctl instead of iwd #210 hunk applied. GitHub reports fix: check for iwctl instead of iwd #210 as not mergeable, and the code comment in its PKGBUILD hunk still says the unit owns PowerManagement.
  • Dead-pid test: resolved. A probe without the kill -0 check now fails the test.
  • PowerManagement owned elsewhere: resolved. The daemon no longer requests that name.
  • Stale holders after the daemon dies and stays down: unchanged. The probe script and omarchy-debug-idle still behave as before.
  • Open Keep the screensaver off while Firefox-family browsers play media #8955: still present. It rewrites the same idleEnabled line and pins that text in its test.
Reproducer: packaging line (fails at 606bd45)

Reproducer: config-test.sh still fails against current omarchy-pkgs

test/shell.d/config-test.sh requires the omarchy-settings PKGBUILD to install default/systemd/user/omarchy-idle-inhibit.service to /usr/lib/systemd/user/. Run at the PR head (606bd45) with OMARCHY_PKGS_PATH pointing at an omarchy-pkgs checkout of master (660cbe3):

$ cd /tmp/omarchy && PATH=/tmp/omarchy/bin:$PATH OMARCHY_PKGS_PATH=/tmp/omarchy-pkgs bash test/shell.d/config-test.sh 2>&1 | tail -3
ok - default right layout keeps agents next to the tray
ok - default bar widget ids resolve to manifests and entry points
PKGBUILD does not explicitly install default/systemd/user/omarchy-idle-inhibit.service -> /usr/lib/systemd/user/omarchy-idle-inhibit.service
[exit status: 1]

With the omarchy-settings and omarchy-settings-dev hunk from omacom/omarchy-pkgs#210 applied to that same master, the file passes at 606bd45 and at 606bd45 merged into quattro e332dc9. quattro alone passes against unmodified master.

([exit status: N] is the exit status of the whole pipeline, run with pipefail.)

Optional notes
  • Optional test improvement: the first-run check reads the batch only up to the omarchy-crash-watch.service line. Appending the unit after that line puts it back into the batch, and the test still passes (ok - first-run enables idle-inhibit separately …). Checking the lines from the one ending in enable --now \ up to the first line without a trailing backslash closes that gap (it fails for the unit before or after crash-watch).
  • Open Enable first-run user units one at a time #10582 rewrites the same first-run batch into a loop that enables one unit at a time. If it lands, the separate enable here is no longer needed for isolation, though the fallback link still is until the packaging line lands.
  • migrations/1790440000.sh still says in its comment that it owns PowerManagement.Inhibit. The unit Description and the command summary still say "names", and inhibitorStatePath in Service.qml is now unused.

Review information

Test scope: Source and sandbox tests at 606bd454; no Quickshell, browser or real user manager.

AI process: Opus 5.5 Medium coordination and synthesis, Opus 5.5 Xhigh technical review and final fact check, GPT 6 Sol Xhigh search for related issues, Opus 5.5 Medium editorial check.

Opt out: To stop receiving these reviews, reply to this comment saying so.

omarchybot and others added 5 commits October 3, 2026 07:03
NameOwnerChanged fires for every name a connection releases, not only its unique name. A browser giving up its MPRIS name while still playing lost every cookie it held, and the screensaver came back over the video. Reap only when the unique name itself goes away.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
enable-user-units.sh now reads OMARCHY_PATH under set -u to find the checkout copy of the idle-inhibit unit, so the test failed wherever the caller had not exported it, and wrote its fallback symlink into the caller's real XDG_CONFIG_HOME where they had.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The daemon leaves org.freedesktop.PowerManagement unowned so background audio cannot hold the lock off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A refresh asked for while the probe was running was dropped, and the probe may already have read the older state. Releasing the last inhibitor in that window left idle suppressed until the next change, so the lock never came back after the video stopped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
The daemon publishes an empty state only from its SIGTERM handler. Killed or crashed with a holder recorded, it left a nonzero count behind, and if systemd could not restart it nothing ever replaced that file, so the screensaver and the automatic lock stayed off for the rest of the session. ExecStopPost runs however the service ends, and removing the file wakes the shell's watcher, whose probe then reads no inhibitors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Oct 3, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed and tested at 00933e5a, which is your branch plus five small fixes I pushed to it. The fix works. It now waits on the packaging line for the unit and on the maintainer.

Reproduced on a worker built from the Omarchy ISO, with the screensaver timeout set to 8 s and a client holding a D-Bus Inhibit the way a browser does:

  • On quattro (a85e29ab), Inhibit fails with ServiceUnknown and the screensaver launches over the held inhibit.
  • On this branch, with the unit installed by its own migration, both /org/freedesktop/ScreenSaver and /ScreenSaver return a cookie, omarchy-shell idle status reports enabled: false, dbusInhibitors: 1, the screensaver stays off for 25 s, and it comes back once the inhibit is released.
  • Removing && dbusInhibitorCount === 0 from idleEnabled brings the bug back with the daemon still running, so the shell half is doing the work.

Pushed to your branch:

  • d0f6b109 — NameOwnerChanged fires for every name a connection drops, not only its unique name. A browser releasing its MPRIS name while still playing lost all its cookies and the screensaver came back. Reaping now happens only when the caller's unique name goes away, with a test.
  • 3a5195ba — a state change that arrived while the probe was running was dropped. If the last inhibitor was released in that window, idle stayed off until the next change. The refresh is now re-run when the probe exits.
  • 00933e5a — the daemon publishes an empty state only from its SIGTERM handler. Killed or crashed while holding an inhibit, with no successful restart, it left a nonzero count, and the lock never came back that session. ExecStopPost now removes the state file however the service stops. On the worker, kill -9 of the daemon with restarts disabled left dbusInhibitors: 1 without the line and 0 with it.
  • 4aa79b92 — owe-integration-test.sh now passes OMARCHY_PATH and a test-local XDG_CONFIG_HOME to enable-user-units.sh, which needs them under set -u since this change.
  • 47d0eb6a — the migration's comment no longer says it owns PowerManagement.

Tests on the worker: idle-inhibit-test.sh, idle-test.sh and owe-integration-test.sh pass. ./test/cli has one failure, vscode generated theme references current theme file, which fails on quattro too. config-test.sh fails, as expected, because the omarchy-settings PKGBUILD does not install omarchy-idle-inhibit.service yet. omacom/omarchy-pkgs#210 adds that line, but it is currently conflicting, and its comment still says the unit owns PowerManagement.

Second opinion: Codex Medium reviewed the whole change three times. Its earlier passes found the well-known-name reaping and the dropped-refresh problems fixed above. Its last pass, on 00933e5a, found nothing further, and it checked that ExecStopPost cannot race a restarted daemon. Its agreement is not independent of my reasoning. Two minor findings were left alone as not worth the code: a publish error is logged rather than retried, and the unit is Type=simple rather than Type=dbus.

Related: this fixes #6475. #6572 takes the same approach but exports only /ScreenSaver, which Chromium does not call. #8955 works around the bug with an MPRIS watch and a window rule for Firefox-family browsers. #8955 also rewrites the same idleEnabled line, so if both land, the two conditions need combining.

Waiting on the maintainer: the packaging line for the unit has to land, and #6572 and #8955 still need a decision.

@greptile-apps

greptile-apps Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 2/5

[Medium risk] Adds a D-Bus daemon to suppress screensaver during playback.

This PR is not ready to merge because a valid inhibitor can be canceled or go unobserved, and a stale observed count can leave automatic locking disabled.

Findings

  1. P1 Old cookies cancel new inhibitors ▶
  2. P1 Failed writes acknowledge inhibition ▶
  3. P1 Lost watch leaves lock disabled ▶
  4. P2 Fallback shadows packaged unit ▶

Summary

This PR adds a session D-Bus ScreenSaver inhibitor daemon, publishes its state for the Quickshell idle service, and enables it for new and existing installations.

  • Supports both ScreenSaver object paths while leaving PowerManagement unowned.
  • Adds state probing, idle-cycle transitions, installation wiring, and tests.
  • The review identified cookie-reuse interference, unsuccessful state publication being acknowledged as success, and a stale-count recovery gap.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Application Inhibit / UnInhibit] --> B[ScreenSaver D-Bus daemon]
  B --> C[Runtime JSON state]
  C --> D[FileView event and state probe]
  D --> E[Quickshell inhibitor count]
  E --> F[Idle monitor, screensaver and lock]
Loading

Reviews (1) · Last reviewed commit: "Clear the inhibit state when the daemon ..."

Comment thread bin/omarchy-idle-inhibit
Comment on lines +149 to +153
def handle_uninhibit(self, params: GLib.Variant, invocation: Gio.DBusMethodInvocation) -> None:
(cookie,) = params.unpack()
self.state.remove(cookie)
self.after_change()
invocation.return_value(None)

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.

P1 Old cookies cancel new inhibitors After the daemon restarts, it assigns cookies from 1 again, but existing clients may still hold cookies from the previous instance. UnInhibit removes a matching cookie without checking who called it, so a client releasing an old cookie can cancel another client's new video inhibitor. The screensaver or lock can then appear during playback.

Comment thread bin/omarchy-idle-inhibit
Comment on lines +146 to +147
self.after_change()
invocation.return_value(GLib.Variant("(u)", (cookie,)))

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.

P1 Failed writes acknowledge inhibition If the runtime filesystem is full and the state write fails, after_change only logs the error while Inhibit still returns a successful cookie. The idle service reads inhibitors only from that file, so its screensaver and lock timers keep running during playback.

Comment on lines +384 to +389
FileView {
id: inhibitorStateDirWatcher
path: root.inhibitorStateDir
watchChanges: true
printErrors: false
onFileChanged: inhibitorProbeDebounce.restart()

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.

P1 Lost watch leaves lock disabled The inhibitor count is refreshed only at startup or after a directory-watch event. This repository already documents that a FileView directory watch can permanently stop reporting changes after rapid updates. If that happens while the count is positive, a later release or daemon-stop file removal is never read, leaving automatic locking disabled indefinitely. Add a recovery path that does not rely on another watch event.

Comment thread migrations/1790440000.sh
Comment on lines +13 to +15
if [[ -f $unit_source ]]; then
mkdir -p "$(dirname "$unit_dest")"
ln -sfn "$unit_source" "$unit_dest"

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.

P2 Fallback shadows packaged unit The migration and first-run setup create a user-level unit symlink when the packaged unit is absent, but neither removes it when the package arrives. Because the user unit takes precedence, those installations continue to ignore later packaged changes to this service. Remove or replace the fallback once the packaged unit exists.

@HerrStolzier

Copy link
Copy Markdown
Contributor Author

Packaging for the unit is now omacom/omarchy-pkgs#779 (MERGEABLE, current master). Same gated install of omarchy-idle-inhibit.service into omarchy-settings and omarchy-settings-dev. Binary is still the omarchy bin/* glob as omarchy-idle-inhibit.

omacom/omarchy-pkgs#210 is still open and conflicting; 779 is the successor (ScreenSaver only, this PR as consumer).

@omarchybot omarchybot removed the verified Omarchy Triage has verified that this issue is ready for final review label Oct 4, 2026
@jandrusk

jandrusk commented Oct 7, 2026

Copy link
Copy Markdown

Thanks for sticking with this. It's a real gap since hypridle went away (#6475). Two things before it can land:

  1. Needs a rebase. It now conflicts with quattro, most likely because of the idle service changes merged Oct 1–4 (Treat idle timeout 0 as disabled, not immediate #12538 and the timeout fixes before it).

  2. Blocking: UnInhibit doesn't check who owns the cookie. handle_uninhibit removes any matching cookie, and cookies start again at 1 every time the daemon starts. A client still holding a cookie from before a restart, or any other client on the session bus, can release someone else's inhibit, and the screensaver or lock then fires over a playing video. Limiting removal to the caller fixes it, and a random starting cookie makes collisions across restarts unlikely:

def remove(self, cookie: int, owner: str) -> None:
  holder = self.cookies.get(int(cookie))
  if holder is not None and holder["owner"] == owner:
    del self.cookies[int(cookie)]

def handle_uninhibit(self, sender, params, invocation) -> None:
  (cookie,) = params.unpack()
  self.state.remove(cookie, sender)
  self.after_change()
  invocation.return_value(None)

# dispatch():   self.handle_uninhibit(sender, params, invocation)
# __init__():   self.next_cookie = random.randint(1, 0x7FFFFFFF)

Should-fix, both from greptile's Oct 3 review:

  • If the state write fails, Inhibit still returns a cookie. The caller thinks it inhibited, but the idle service never sees it. Returning a D-Bus error (and dropping the cookie) when publish() raises would be safer.
  • The shell only re-reads the state when the directory watch fires. If that watch goes quiet while the count is above 0, auto-lock stays off until the shell restarts. A slow re-read timer while dbusInhibitorCount > 0 (every 30 s, say) would put a limit on that.

The packaging side (omacom/omarchy-pkgs#779) also has to land, or config-test.sh stays red.

@eesoymilk

Copy link
Copy Markdown

Thanks for the groundwork on this.
I opened #16533, which builds on it: same D-Bus behavior, plus the cookie ownership check from the review.
The difference is that the helper runs as a child process of the idle service instead of a systemd unit with a state file, so there's no unit, migration or omarchy-pkgs change, and the two should-fix items about the state file no longer apply.

@omarchybot

Copy link
Copy Markdown
Collaborator

Classification now agrees on bug. I reproduced the missing receiver on current quattro (778f827b) in a disposable ISO worker: the D-Bus Inhibit request returned ServiceUnknown, then the screensaver started at the shortened eight-second timeout.

I tested a local, unpushed candidate (4167a19ec37195901ed4ea4e0a13cee6f9ba9bea) that resolves the conflicts with current quattro, carries @eesoymilk’s cookie ownership check, randomized starting cookie and cross-client regression coverage from #16533, and returns an error rather than acknowledging an inhibit whose state could not be published. The live PR remains at 00933e5a; these changes have not been pushed.

On that candidate, a synthetic D-Bus holder kept the screensaver off, including across a shell restart with the same daemon PID. Releasing it allowed the screensaver to run again. Removing the shell’s inhibit gate brought the failure back while the daemon still reported one holder. Reverting the ownership check and the publication fix separately also made the regression test fail. This did not exercise a real browser or a call.

./test/cli, idle-inhibit-test.sh, idle-test.sh, owe-integration-test.sh and shell-idle-spawn-test.sh passed. config-test.sh passes on the base and fails on the candidate: the current package still does not install omarchy-idle-inhibit.service. omacom/omarchy-pkgs#779 remains open. The live check staged the executable and linked the unit on the worker, so it does not prove package delivery. The worker has been destroyed.

GPT-6 High in Codex performed this review. Opus 5.5 High returned a written source review, including test gaps I checked: the probe lacks a live-PID success case, the private-bus scenarios reuse their state file, and the first-run structure assertion is obsolete after the base switched to enabling units individually. Those remain open in the local candidate. Both panel commands ended with status 143 before recording their final reviewer metadata; the supplementary reviewer produced no report. A separate omabot review --ping succeeded, so this is an interrupted review, not a claim that reviewers were unavailable. No clean final review is claimed, and agreement in the written report is not guaranteed to be independent of this session’s notes.

The push is withheld because the protocol requires green tests. The #16533 handoff remains pending. Waiting on the maintainer for the packaging dependency and the choice among the open implementations; the live PR still conflicts with quattro.

Base: the screensaver starts after the D-Bus request is rejected

Unpushed candidate: the desktop remains visible while the synthetic inhibit is held across a shell restart

Candidate with its shell inhibit gate removed: the screensaver returns despite a held inhibit

emirb added a commit that referenced this pull request Nov 28, 2026
* Own org.freedesktop.ScreenSaver in the idle service

Since the Quickshell idle service replaced hypridle, nothing on the
session bus owns org.freedesktop.ScreenSaver. Chromium, Chrome, Brave,
Electron, Steam, and xdg-desktop-portal-gtk send video and display wake
locks to /org/freedesktop/ScreenSaver, and Firefox, Zen, and VLC use
/ScreenSaver. Those requests fail with ServiceUnknown, so the screensaver
and lock fire over playing video (including fullscreen Netflix and
YouTube).

Run a small PyGObject helper (screensaver.py) as a child Process of
IdleService:
- owns org.freedesktop.ScreenSaver on both /org/freedesktop/ScreenSaver
  and /ScreenSaver;
- leaves org.freedesktop.PowerManagement unowned so Chromium audio-only
  tabs, downloads, and WebRTC never pin the screensaver or lock off;
- allocates random nonzero cookies (avoiding 0, which
  xdg-desktop-portal-gtk skips on UnInhibit), enforces per-caller
  ownership on UnInhibit, caps outstanding inhibitors at 256, and reaps
  a caller only when its unique bus name vanishes;
- exits promptly when stdin closes, stdout breaks, or no session bus
  exists, and restarts after 5s on unexpected crashes.

IdleService folds active app inhibitors into idleEnabled without writing
the user stay-awake file, stops an active idle-launched screensaver when
an inhibitor arrives, flips stayAwake directly in idle toggle, and lists
appInhibitors in idle status.

Builds on #16533 (@eesoymilk) and #13359 (@HerrStolzier).

* Use OMARCHY_PATH directly and test broken-pipe and no-bus exits

Rely directly on Quickshell.env("OMARCHY_PATH") for screensaver.py per
AGENTS.md instead of deriving a fallback path. Also silence Python's exit
stdout flush after BrokenPipeError and cover both broken-stdout and
missing-session-bus exits in test/shell.d/idle-test.sh.

* Use /usr/bin/python3, cancel launching screensaver, and flush broken-pipe error

Invoke /usr/bin/python3 directly so a mise or PATH Python without system
python-gobject cannot break the ScreenSaver helper. Stop an in-flight
screensaver launch process when an app inhibit arrives, and flush the
D-Bus connection before exiting on BrokenPipeError so the caller receives
the error reply reliably.
@emirb

emirb commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Thanks @HerrStolzier merged via #20606

@emirb emirb closed this Nov 28, 2026
cursor Bot pushed a commit to mark-groves/omarchy that referenced this pull request Nov 28, 2026
* Own org.freedesktop.ScreenSaver in the idle service

Since the Quickshell idle service replaced hypridle, nothing on the
session bus owns org.freedesktop.ScreenSaver. Chromium, Chrome, Brave,
Electron, Steam, and xdg-desktop-portal-gtk send video and display wake
locks to /org/freedesktop/ScreenSaver, and Firefox, Zen, and VLC use
/ScreenSaver. Those requests fail with ServiceUnknown, so the screensaver
and lock fire over playing video (including fullscreen Netflix and
YouTube).

Run a small PyGObject helper (screensaver.py) as a child Process of
IdleService:
- owns org.freedesktop.ScreenSaver on both /org/freedesktop/ScreenSaver
  and /ScreenSaver;
- leaves org.freedesktop.PowerManagement unowned so Chromium audio-only
  tabs, downloads, and WebRTC never pin the screensaver or lock off;
- allocates random nonzero cookies (avoiding 0, which
  xdg-desktop-portal-gtk skips on UnInhibit), enforces per-caller
  ownership on UnInhibit, caps outstanding inhibitors at 256, and reaps
  a caller only when its unique bus name vanishes;
- exits promptly when stdin closes, stdout breaks, or no session bus
  exists, and restarts after 5s on unexpected crashes.

IdleService folds active app inhibitors into idleEnabled without writing
the user stay-awake file, stops an active idle-launched screensaver when
an inhibitor arrives, flips stayAwake directly in idle toggle, and lists
appInhibitors in idle status.

Builds on omacom#16533 (@eesoymilk) and omacom#13359 (@HerrStolzier).

* Use OMARCHY_PATH directly and test broken-pipe and no-bus exits

Rely directly on Quickshell.env("OMARCHY_PATH") for screensaver.py per
AGENTS.md instead of deriving a fallback path. Also silence Python's exit
stdout flush after BrokenPipeError and cover both broken-stdout and
missing-session-bus exits in test/shell.d/idle-test.sh.

* Use /usr/bin/python3, cancel launching screensaver, and flush broken-pipe error

Invoke /usr/bin/python3 directly so a mise or PATH Python without system
python-gobject cannot break the ScreenSaver helper. Stop an in-flight
screensaver launch process when an app inhibit arrives, and flush the
D-Bus connection before exiting on BrokenPipeError so the caller receives
the error reply reliably.
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.

[Quattro] D-Bus idle inhibits are silently dropped since hypridle was replaced — screensaver fires during video playback (reproduced with Zen browser)

6 participants