Repository navigation
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Pull request overview
Reintroduces D-Bus idle inhibition for applications using org.freedesktop.ScreenSaver.
Changes:
- Adds an inhibitor daemon and systemd service.
- Integrates inhibitor state with Quickshell idle handling.
- Adds migration, dependency, diagnostics, and tests.
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.
Reviewed changes
Copilot reviewed 5 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
bin/omarchy-idle-inhibit |
Implements the D-Bus daemon. |
bin/omarchy-debug-idle |
Displays active D-Bus inhibitors. |
default/systemd/user/omarchy-idle-inhibit.service |
Runs the daemon per session. |
install/omarchy-base.packages |
Adds the Python D-Bus dependency. |
migrations/1785963476.sh |
Enables the service for existing users. |
shell/plugins/services/idle/Service.qml |
Connects inhibitor state to idle behavior. |
test/shell.d/idle-inhibit-test.sh |
Tests diagnostics and metadata. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| function handleInhibitorStateChanged() { | ||
| var previous = root.dbusInhibitorCount | ||
|
|
||
| if (previous === 0 && root.dbusInhibitorCount > 0) { | ||
| // An app started inhibiting mid-cycle: pull back the screensaver/lock. | ||
| if (root.idledThisCycle) root.cancelIdleCycle("dbus-inhibit") | ||
| } else if (previous > 0 && root.dbusInhibitorCount === 0) { | ||
| // All inhibitors released: re-arm idle from the current monitor state. | ||
| logEvent("dbus-inhibit", "cleared") | ||
| Qt.callLater(root.handleIdleChanged) | ||
| } | ||
| } | ||
|
|
||
| function parseInhibitorState(text) { | ||
| var raw = text !== undefined ? text : "" | ||
| if (!raw || !raw.length) return | ||
|
|
||
| var parsed = JSON.parse(raw) | ||
| if (parsed && typeof parsed.count === "number") { | ||
| var count = parsed.count | ||
| if (count !== root.dbusInhibitorCount) { | ||
| logEvent("dbus-inhibit", "count=" + count) | ||
| root.dbusInhibitorCount = count | ||
| root.handleInhibitorStateChanged() |
There was a problem hiding this comment.
Fixed. parseInhibitorState now captures the old count into previous before overwriting root.dbusInhibitorCount, and handleInhibitorStateChanged(previous) takes it as an argument — so the 0 → >0 and >0 → 0 transition branches can actually distinguish added from removed inhibitors. I also added an idleEnabled guard at the top of launchScreensaver(), so a screensaver timer armed before an inhibitor arrived can no longer blank the screen.
|
|
||
| [Service] | ||
| Type=simple | ||
| ExecStart=/usr/bin/omarchy-idle-inhibit |
There was a problem hiding this comment.
Fixed on the test side: the unit is now in the package_defaults mapping in test/shell.d/config-test.sh (default/systemd/user/omarchy-idle-inhibit.service → /usr/lib/systemd/user/omarchy-idle-inhibit.service), alongside every other shipped user unit, so the settings PKGBUILD is verified to install it. The migration was also made self-sufficient for the case where the package unit has not landed yet (e.g. a local checkout update that ships migrations before the rebuilt package): it now installs a user copy at ~/.config/systemd/user/ when /usr/lib/systemd/user/omarchy-idle-inhibit.service is absent, then systemctl --user enable --now finds the unit either way.
| [Install] | ||
| WantedBy=graphical-session.target |
There was a problem hiding this comment.
Fixed. omarchy-idle-inhibit.service is now added to the first-run enable list in install/user/first-run/enable-user-units.sh, so fresh installs start the daemon immediately rather than leaving it disabled. Existing installs get it through the new migration.
| FileView { | ||
| path: root.inhibitorStateDir | ||
| watchChanges: true | ||
| printErrors: false | ||
| onFileChanged: inhibitorStateProbe.running = true |
There was a problem hiding this comment.
Fixed with a debounce. The directory watcher now restarts a 50 ms Timer (inhibitorProbeDebounce) instead of setting inhibitorStateProbe.running = true directly. The daemon's atomic write emits two directory events (temp create + rename); the debounce collapses them into a single probe after they settle, so the second event can no longer be dropped because the process is already running. Verified live: inhibit and uninhibit both update the count immediately, including when the daemon creates the state file after the shell has started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 9 changed files in this pull request and generated 2 comments.
Suppressed comments (1)
test/shell.d/idle-inhibit-test.sh:42
- This check only parses the Python source and inspects metadata, so it does not exercise the new daemon’s primary D-Bus contract. Add a focused
dbus-run-sessiontest that starts the daemon with a temporary state file, callsInhibit/UnInhibitthrough the supported object paths, verifies state transitions, and verifies cleanup when a caller disconnects; otherwise path/signature/lifetime regressions all pass this suite.
# The daemon binary is syntactically valid and declares its command metadata.
python3 -c "import ast; ast.parse(open('$ROOT/bin/omarchy-idle-inhibit').read())" \
|| fail "idle-inhibit daemon is valid python"
| var parsed = JSON.parse(raw) | ||
| if (parsed && typeof parsed.count === "number") { | ||
| var count = parsed.count | ||
| if (count !== root.dbusInhibitorCount) { | ||
| // Capture the old count before overwriting it so the handler can tell | ||
| // whether inhibitors were added or removed. | ||
| var previous = root.dbusInhibitorCount | ||
| root.dbusInhibitorCount = count | ||
| logEvent("dbus-inhibit", "count=" + count) | ||
| root.handleInhibitorStateChanged(previous) | ||
| } | ||
| } |
There was a problem hiding this comment.
Fixed. parseInhibitorState now defaults to count 0 and treats any object without a numeric count (or unparseable JSON) as zero, so the probe's {} fallback clears a stale nonzero count. Verified live: with an active inhibitor, removing the state file flips dbusInhibitors 1 → 0 and logs dbus-inhibit: cleared, re-arming idle instead of disabling the lock indefinitely.
| cp "$unit_source" "$unit_dest" | ||
| fi | ||
|
|
||
| systemctl --user enable --now omarchy-idle-inhibit.service >/dev/null 2>&1 || true |
There was a problem hiding this comment.
Fixed. The migration now checks omarchy-pkg-missing python-dbus and calls omarchy-pkg-add python-dbus before enabling the service, so existing users who update via pacman -Syu get the runtime dependency even though install/omarchy-base.packages is only reconciled for fresh installs.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 9 changed files in this pull request and generated no new comments.
Suppressed comments (1)
migrations/1785963476.sh:24
- This copied unit permanently shadows
/usr/lib/systemd/user/omarchy-idle-inhibit.service, because files under the user's systemd directory have higher precedence. A user who takes this local-checkout fallback will therefore never receive later packaged unit fixes. Make the fallback track the checkout rather than leaving a stale copy.
cp "$unit_source" "$unit_dest"
|
All review feedback is addressed across the follow-up commits: Round 2 (review comments 1–4):
Round 3 (new comments 5–6): Suppressed suggestions:
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 9 changed files in this pull request and generated no new comments.
Suppressed comments (3)
migrations/1785963476.sh:27
- This migration can run from a TTY/SSH session with no live user manager; in that case
systemctl --user enablefails,|| truehides it, and the runner permanently marks the migration complete without creating thegraphical-session.target.wantslink. The daemon then remains disabled at the next graphical login. Use the offline symlink fallback already established inmigrations/1785167800.sh:8-25, and only start the unit when the graphical target is active.
fi
shell/plugins/services/idle/Service.qml:204
- The new shell test exercises the daemon and debug rendering, but it never exercises this QML-side parser or the
0 → active → 0cancel/re-arm transitions that actually connect D-Bus inhibition to idle behavior. Extract the state parsing/transition decision intoIdleModel.js(as other idle logic is) and add focused cases totest/shell.d/idle-test.shso malformed/missing state and both transitions cannot regress unnoticed.
function parseInhibitorState(text) {
var raw = text !== undefined ? text : ""
if (!raw || !raw.length) return
test/shell.d/idle-inhibit-test.sh:88
dbus-run-sessionterminates its private bus after the foregroundbashexits, but it does not terminate arbitrary background children. The daemon has no bus-disconnect exit handler, so every scenario leaves an idle daemon running indefinitely (and the holding clients survive until their sleep ends), leaking processes across the test suite. Add an EXIT trap inside the private session to terminate and reap all background jobs.
dbus-run-session -- bash -c "
python3 '$ROOT/bin/omarchy-idle-inhibit' --state-file '$daemon_state' >>'$daemon_log' 2>&1 &
echo \$! >'$test_tmp/daemon.pid'
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 9 changed files in this pull request and generated no new comments.
Suppressed comments (1)
test/shell.d/idle-inhibit-test.sh:88
- Each scenario backgrounds the daemon (and two scenarios also background a client), but the nested shell never terminates or waits for those jobs.
dbus-run-sessionstops its bus only; it does not reap these descendants, so this test leaves multiple daemon processes running after completion. Add an EXIT trap in the nested shell to kill and wait for all background jobs.
python3 '$ROOT/bin/omarchy-idle-inhibit' --state-file '$daemon_state' >>'$daemon_log' 2>&1 &
|
Addressed the remaining suppressed suggestions in commit ccf73fd:
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 11 changed files in this pull request and generated no new comments.
Suppressed comments (2)
migrations/1785963476.sh:38
- When
systemctl --user enablefails because no user manager is available, the packaged-unit case leavesunit_destnonexistent: it is only created when/usr/lib/systemd/user/omarchy-idle-inhibit.serviceis absent. This fallback therefore writes a broken wants symlink on the normal packaged update path, so the daemon will not start at the next graphical login. Select/usr/lib/systemd/user/omarchy-idle-inhibit.servicewhen it exists and useunit_destonly for the checkout fallback.
ln -sfn "$unit_dest" "$wants_dir/omarchy-idle-inhibit.service"
test/shell.d/idle-inhibit-test.sh:90
- This trap sends signals but never waits for the background daemon/client to exit, despite the comment claiming they cannot leak. The daemon handles SIGTERM asynchronously and writes zero during shutdown, so it can survive
dbus-run-sessionlong enough to overwrite the shareddaemon_stateduring a later scenario (or race the outer temp-directory cleanup), making this test flaky. Reap the jobs after killing them.
trap 'kill \$(jobs -p) 2>/dev/null || true; wait 2>/dev/null || true' EXIT
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 11 changed files in this pull request and generated no new comments.
Suppressed comments (2)
migrations/1785963476.sh:39
- When
systemctl --user enablefails while the packaged unit exists,unit_destwas never created because lines 24–27 only create it when/usr/lib/systemd/user/...is absent. This fallback therefore installs a dangling wants symlink and the daemon will not start at the next graphical login. Select the packaged unit as the link target when it exists.
if ! systemctl --user enable omarchy-idle-inhibit.service >/dev/null 2>&1; then
wants_dir="$user_config_home/systemd/user/graphical-session.target.wants"
mkdir -p "$wants_dir"
ln -sfn "$unit_dest" "$wants_dir/omarchy-idle-inhibit.service"
fi
shell/plugins/services/idle/Service.qml:27
idleEnabledis also the state used by theidle toggleIPC method at line 426. Making it false for a transient D-Bus inhibitor meanstoggleno longer toggles the user's stay-awake preference: with no stay-awake flag it tries to enable idle and does nothing, while with the flag set it clears it, unexpectedly enabling idle once the inhibitor disappears. Keep the effective inhibited state separate, or make the IPC toggle derive its next value fromstayAwakerather thanidleEnabled.
readonly property bool idleEnabled: stayAwakeStateLoaded && !stayAwake && dbusInhibitorCount === 0
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 11 changed files in this pull request and generated no new comments.
Suppressed comments (1)
shell/plugins/services/idle/Service.qml:27
- Including transient D-Bus inhibition in
idleEnabledbreaks the existingidle.toggleIPC behavior. While an app inhibits idle,idleEnabledis false even whenstayAwakeis false, sotoggle()at line 426 callssetIdleEnabled(true)and becomes a no-op instead of enabling Stay Awake. Base the toggle decision on the persisted/manualstayAwakestate (or split manual enablement from effective inhibition).
readonly property bool idleEnabled: stayAwakeStateLoaded && !stayAwake && dbusInhibitorCount === 0
|
The toggle-derived-from-idleEnabled concern is fixed in commit 094c0cb: |
hypridle natively owned org.freedesktop.ScreenSaver on the session bus, so apps playing video (Firefox, Chromium, Zen, VLC) could call Inhibit() to keep the screensaver from firing. When Quattro replaced hypridle with the Quickshell idle service, that D-Bus role was never reimplemented, so Inhibit() calls are silently dropped and the screensaver fires during playback. Add a small daemon that re-owns the name and tracks active Inhibits in a state file the idle service watches. The service suppresses idle while any inhibitor is active, exactly as hypridle did. Fix omacom#6475. Co-Authored-By: Claude <noreply@anthropic.com>
- Capture the previous inhibitor count before overwriting it so the transition handler can tell added from removed inhibitors; guard launchScreensaver against an inhibitor arriving while the timer runs. - Ship the unit to /usr/lib/systemd/user in the package mapping and enable it at first run for fresh installs, not just via migration. - Make the migration self-sufficient when the package unit has not landed yet by installing a user copy before enabling. - Debounce the directory watcher: the daemon's atomic rename emits two events and a process already running would not be restarted, leaving a stale count. Co-Authored-By: Claude <noreply@anthropic.com>
- Treat a missing or unreadable inhibitor state file as zero inhibitors so a
daemon failure clears a stale nonzero count instead of disabling the lock
indefinitely (the probe emits {} when the file is gone).
- Install python-dbus in the migration before enabling the daemon, since
`omarchy update` runs `pacman -Syu` and does not reconcile the base package
manifest for existing users.
Co-Authored-By: Claude <noreply@anthropic.com>
…ract - Track each inhibitor's owning connection and release it on NameOwnerChanged when that connection leaves the bus, so a crashed browser or killed tab can't keep the screen awake forever. - Exercise the daemon's actual D-Bus contract over a private bus with dbus-run-session: name ownership, Inhibit/UnInhibit state transitions, and release-on-disconnect. Co-Authored-By: Claude <noreply@anthropic.com>
A copied unit at ~/.config/systemd/user permanently shadows the packaged /usr/lib/systemd/user unit (user precedence), so users who took the fallback would never receive later packaged fixes. Symlink to the checkout instead so the enabled unit tracks its source. Also daemon-reload before enabling so the linked unit is seen. Co-Authored-By: Claude <noreply@anthropic.com>
- Migration: fall back to writing the graphical-session.target.wants symlink when systemctl enable fails (TTY/SSH update has no live user manager), and only start the unit inside a graphical session. Matches the fcitx5 migration pattern so the daemon isn't stranded at the next login. - Move inhibitor state parsing and the cancel/re-arm transition decision into IdleModel.js so the shell test can exercise malformed/missing state and both transitions, not just the daemon's D-Bus side. - Kill background children on exit inside the dbus-run-session scenarios so a test run can't leak idle daemons or holding clients. Co-Authored-By: Claude <noreply@anthropic.com>
The EXIT trap killed each scenario's background children but did not wait on them after the kill, so a descendant could still be terminating when the bus went down. Kill and wait so a scenario cannot leak a daemon or holding client. Co-Authored-By: Claude <noreply@anthropic.com>
…hildren - In the migration's offline fallback, resolve the wants symlink target to /usr/lib/systemd/user/omarchy-idle-inhibit.service when the packaged unit exists, using the user-dir checkout link only when it does not. The previous code always symlinked the checkout fallback path, which does not exist on a normal packaged update and produced a broken wants link. - In the test scenarios, SIGKILL (not SIGTERM) and wait on exit so the daemon's shutdown handler cannot asynchronously write zero over the shared state file and race a later scenario. Co-Authored-By: Claude <noreply@anthropic.com>
…tate idleEnabled is false while a D-Bus inhibitor is active, so the `idle toggle` IPC method deriving its next value from idleEnabled dropped toggles issued during playback: "enable idle" succeeded at nothing, and "stay awake" cleared the flag so idle unexpectedly re-armed once the inhibitor was released. Flip stayAwake (the user's actual preference) instead. Co-Authored-By: Claude <noreply@anthropic.com>
|
Currently running into this issue using Stremio. Omarchy goes to sleep while a video is playing |
|
Tested this PR locally on Omarchy 4.0.4-1 (kernel What works
Gap for Chromium/Chrome This daemon only exports
So this would restore inhibit for clients that talk to Rebase Head is ~746 commits behind Happy to re-test a revision that also exports |
|
Reviewed at What this one misses. Checked here: the diff, read against #13359's. Both derive Not run: I did not run this branch on a worker, because a fix that is not the recommended one would only spend a test machine. Second opinion: none for this review. The configured reviewer, Codex Medium, answered a ping but had used up its daily review budget. An earlier Codex Medium review, run while #13359 was being reviewed, compared the two and also picked #13359 because this one misses Chromium's path. That review read this branch from the fork rather than the pinned commit, and its agreement is not independent of the reasoning here. Waiting on the maintainer to choose between this and #13359. |
Summary
Re-implements the D-Bus idle-inhibit support that was lost when Quattro replaced
hypridlewith the Quickshell idle service.hypridlenatively ownedorg.freedesktop.ScreenSaveron the session bus, so apps playing video (Firefox, Chromium, Zen, VLC) could callInhibit()to keep the screensaver from firing. That role was never reimplemented in the Quattro switch, so thoseInhibit()calls are silently dropped and the screensaver fires during playback.What changed
bin/omarchy-idle-inhibit— a small Python daemon that ownsorg.freedesktop.ScreenSaveron the session bus, tracks activeInhibit()/UnInhibit()calls, and writes the count + detail list to a state file. Self-heals on restart (writes count 0 on startup and on SIGTERM).default/systemd/user/omarchy-idle-inhibit.service— user service that launches the daemon withRestart=always.shell/plugins/services/idle/Service.qml— watches the state file and folds the D-Bus inhibitor count intoidleEnabled, so any active inhibitor suppresses the screensaver and lock (pulls back an active idle cycle, re-arms when cleared).bin/omarchy-debug-idle— renders the active D-Bus inhibitors (app/reason/cookie) for observability.migrations/1785963476.sh— enables the service for existing Quattro users.install/omarchy-base.packages— addspython-dbusfor the daemon.test/shell.d/idle-inhibit-test.sh— covers the debug rendering and daemon metadata.Notes
Quickshell's
FileViewcannot observe a file that doesn't exist yet, and the daemon creates the state file around the same time the shell starts. To stay correct under that race, the idle service watches the parent directory (mirroring the existingbarHiddenProbe/togglespattern inBar.qml) and re-probes the file via aProcess. Verified live on the desktop: the shell picks up the file even when the daemon creates it after the shell has started.The daemon answers raw GDBus calls (verified with
gdbus call), which is what real browsers use.