Repository navigation
Stop re-sampling the wallpaper for the transparent bar on unrelated state writes - #8307
Conversation
…tate writes The bar watched ~/.local/state/omarchy/current for background changes. A directory path never sits in QFileSystemWatcher's file set, so Quickshell's FileView re-emitted fileChanged for every entry created, renamed or removed in ~/.local/state/omarchy as well. Any plugin writing there atomically (tmp + rename) re-ran omarchy-bar-text-color, and on a 5K display that ImageMagick pass cost ~2.6 core-seconds across every thread. One plugin saving every 10 s held ~40% of a core for the whole session, invisible in quickshell's own CPU figure because magick is a reaped grandchild. Watching the symlink directly does not work: inotify follows it to the old image and ln -nsf never touches that inode. Keep the directory watch, resolve the link with readlink -f and only refresh when the wallpaper actually moved. Sample at a reduced scale in omarchy-bar-text-color too. The strip is averaged to one pixel, so shrink the geometry by an integer factor (never upscale) and let the JPEG decoder skip the detail: 2.58 -> 0.065 core-seconds per sample on a 2912x1632 JPEG at 5120x2160, same result.
There was a problem hiding this comment.
Pull request overview
Prevents unrelated state writes from repeatedly triggering wallpaper sampling and reduces sampling cost.
Changes:
- Filters wallpaper events by resolved background path.
- Downscales sampling geometry and limits ImageMagick threads.
- Adds reduced-scale sampling 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 2 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
shell/plugins/bar/Bar.qml |
Filters and coalesces background-change events. |
bin/omarchy-bar-text-color |
Reduces wallpaper sampling cost. |
test/shell.d/bar-text-color-test.sh |
Tests reduced-scale sampling. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| Process { | ||
| id: transparentBackgroundProbe | ||
| property bool rerun: false | ||
| command: ["readlink", "-f", root.stateHome + "/omarchy/current/background"] |
| onFileChanged: { | ||
| if (transparentBackgroundProbe.running) transparentBackgroundProbe.rerun = true | ||
| else transparentBackgroundProbe.running = true | ||
| } |
…untime smoke test FileView reports no change for its initial load, so without a baseline the first unrelated write in the state directory still compared against "" and sampled once. Run the probe when the bar starts. The smoke test now stubs omarchy-bar-text-color and counts calls in the running shell: turning transparency on samples once, an atomic write of an unrelated file in ~/.local/state/omarchy does not sample again, and repointing current/background does. Against the previous Bar.qml the unrelated write registers as a second sample and the test fails.
Resolve two conflicts. omarchy-bar-text-color keeps quattro's first-frame selector for video backgrounds on the reduced-scale sampling. The runtime smoke test's wallpaper-sampling checks run on the default bar, before quattro's replacement-bar probes, which it keeps last. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Reviewed by Claude Opus 5.5. The second opinion (Codex) did not run: its daily review budget was spent, so only one model has read this. Merged The bug reproduces, and the fix holds. Tested on a fresh Omarchy VM with the shell running from this branch:
One narrow gap, not fixed here. Deciding by the resolved path alone misses a wallpaper change when the path string stays the same. Related: #10289, where the bar keeps the previous theme's text colour because a refresh requested while a sample is running gets dropped, is a separate bug that this does not fix. The 13x cheaper sample does shrink the window it needs. #12115 edits the same Waiting on the maintainer. It is labelled |
Both conflicts resolve to quattro's side. bin/omarchy-bar-text-color takes omacom#14281's bounded sampling, which covers this branch's downscale. test/shell.d/runtime-smoke-test.sh was restructured on quattro, so the bar test is rewritten against it in a later commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The merge took quattro's omarchy-bar-text-color, whose 1920px canvas, JPEG size hint and resource caps from omacom#14281 already bound the sample this branch shrank, so its tests for the old downscale go with it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
FileView watches its path's parent directory too, and re-emits fileChanged for every entry created, renamed or removed there whenever the path itself is not a watched file. Watching ~/.local/state/omarchy/current made that parent ~/.local/state/omarchy, which plugins write to constantly, so the transparent bar re-ran ImageMagick on every unrelated save. Watching current/theme moves the parent to current/, where omarchy-theme-set swaps the theme and omarchy-theme-bg-set repoints the background link, and both still arrive. This replaces a readlink probe that resolved the link on every event: no extra process, and a theme switch that lands on a same-named background still re-samples. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Codex Medium <noreply@openai.com>
[Low impact] The PR appears safe to merge; no actionable issues were found. SummaryNarrows the transparent bar’s file watch to avoid wallpaper sampling after unrelated state writes.
No actionable issues found. The diff does not include the ImageMagick changes described in the PR. Runtime tests were not run. Reviews (1) · Last reviewed commit: "Watch inside current/ so unrelated state..." · Reviewed by Greptile |
|
Thanks @ryanyogan. Your diagnosis holds on current quattro, and the branch now carries a smaller version of your fix. The bug is real. On an Omarchy ISO worker running quattro with the bar transparent, five rounds of unrelated writes into What I pushed (b443388):
Checked on the worker with this branch linked into the running session: unrelated writes ran the helper zero times. Second opinion: Codex Medium and muse-spark-1.3-contributor (thinking high) reviewed it over two rounds, the second on the pushed head. They found nothing blocking. Codex noted that writes inside Related: #14220 merges cleanly on top and keeps this watch as its fallback. #14148 gates this same This is waiting on the maintainer. |
…tate writes (#8307) (#16799) * Stop re-sampling the wallpaper for the transparent bar on unrelated state writes The bar watched ~/.local/state/omarchy/current for background changes. A directory path never sits in QFileSystemWatcher's file set, so Quickshell's FileView re-emitted fileChanged for every entry created, renamed or removed in ~/.local/state/omarchy as well. Any plugin writing there atomically (tmp + rename) re-ran omarchy-bar-text-color, and on a 5K display that ImageMagick pass cost ~2.6 core-seconds across every thread. One plugin saving every 10 s held ~40% of a core for the whole session, invisible in quickshell's own CPU figure because magick is a reaped grandchild. Watching the symlink directly does not work: inotify follows it to the old image and ln -nsf never touches that inode. Keep the directory watch, resolve the link with readlink -f and only refresh when the wallpaper actually moved. Sample at a reduced scale in omarchy-bar-text-color too. The strip is averaged to one pixel, so shrink the geometry by an integer factor (never upscale) and let the JPEG decoder skip the detail: 2.58 -> 0.065 core-seconds per sample on a 2912x1632 JPEG at 5120x2160, same result. * Resolve the background link at startup and cover the watcher in the runtime smoke test FileView reports no change for its initial load, so without a baseline the first unrelated write in the state directory still compared against "" and sampled once. Run the probe when the bar starts. The smoke test now stubs omarchy-bar-text-color and counts calls in the running shell: turning transparency on samples once, an atomic write of an unrelated file in ~/.local/state/omarchy does not sample again, and repointing current/background does. Against the previous Bar.qml the unrelated write registers as a second sample and the test fails. * Drop the reduced-scale helper tests, which #14281 covers The merge took quattro's omarchy-bar-text-color, whose 1920px canvas, JPEG size hint and resource caps from #14281 already bound the sample this branch shrank, so its tests for the old downscale go with it. * Watch inside current/ so unrelated state writes do not re-sample the bar FileView watches its path's parent directory too, and re-emits fileChanged for every entry created, renamed or removed there whenever the path itself is not a watched file. Watching ~/.local/state/omarchy/current made that parent ~/.local/state/omarchy, which plugins write to constantly, so the transparent bar re-ran ImageMagick on every unrelated save. Watching current/theme moves the parent to current/, where omarchy-theme-set swaps the theme and omarchy-theme-bg-set repoints the background link, and both still arrive. This replaces a readlink probe that resolved the link on every event: no extra process, and a theme switch that lands on a same-named background still re-samples. --------- (cherry picked from commit bc220e7) Co-authored-by: Ryan Yogan <ryanyogan@gmail.com> Co-authored-by: Omarchybot <317366263+omarchybot@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Codex Medium <noreply@openai.com>
…#16859) The transparent bar check from #8307 sets the bar's background with omarchy-bar, which edits shell.json from outside the shell. Elsewhen saves its first-run cities once its timezone probe returns, and that save writes the shell's whole in-memory config back to shell.json. When the probe returns after the edit, the file goes back to an opaque bar, the bar never turns transparent and nothing samples the wallpaper. On a desktop the probe returns before the test gets there. In a VM it returned later in 7 of 8 runs: the file read "background": "opaque" with Elsewhen's cities saved, 30 s after omarchy-bar had reported "Bar background set to none". The unreadable shell.json checks further down already waited for that save. The wait is now one helper, called before both edits, and allows 30 s, since it returns as soon as the cities are saved.
…omacom#16859) The transparent bar check from omacom#8307 sets the bar's background with omarchy-bar, which edits shell.json from outside the shell. Elsewhen saves its first-run cities once its timezone probe returns, and that save writes the shell's whole in-memory config back to shell.json. When the probe returns after the edit, the file goes back to an opaque bar, the bar never turns transparent and nothing samples the wallpaper. On a desktop the probe returns before the test gets there. In a VM it returned later in 7 of 8 runs: the file read "background": "opaque" with Elsewhen's cities saved, 30 s after omarchy-bar had reported "Bar background set to none". The unreadable shell.json checks further down already waited for that save. The wait is now one helper, called before both edits, and allows 30 s, since it returns as soon as the cities are saved.
* Wait for Elsewhen's first save before the smoke test edits shell.json (#16859) The transparent bar check from #8307 sets the bar's background with omarchy-bar, which edits shell.json from outside the shell. Elsewhen saves its first-run cities once its timezone probe returns, and that save writes the shell's whole in-memory config back to shell.json. When the probe returns after the edit, the file goes back to an opaque bar, the bar never turns transparent and nothing samples the wallpaper. On a desktop the probe returns before the test gets there. In a VM it returned later in 7 of 8 runs: the file read "background": "opaque" with Elsewhen's cities saved, 30 s after omarchy-bar had reported "Bar background set to none". The unreadable shell.json checks further down already waited for that save. The wait is now one helper, called before both edits, and allows 30 s, since it returns as soon as the cities are saved. (cherry picked from commit 63b6e5b) * Replace the i18n startup test's watched files whole (#16886) The live probe edits files the shell watches: the catalogs, the language selection and the plugin directory. It wrote them in place, which truncates first, and Quickshell's FileView reloads on the change, so a reload between the truncation and the write reads an empty file. With an empty catalog or plugin directory, t("test.hello") returns its key and .arg("Ada") logs "QString::arg: Argument missing", which fails the final log check. CI hit this on a loaded runner. Write each file beside its target and rename it over, so a reload reads either the old file or the new one. In a VM with every vCPU kept busy, the test failed 10 of 40 runs on that warning before this change and 0 of 40 after. Renaming only the catalogs was not enough (13 of 40 failed): the language and plugin directory files are watched too. (cherry picked from commit e6c6a18) * Wait for the input-indicator test's fake Fcitx to finish its exec (#16887) The test starts sleep with FCITX_CONFIG_HOME set and at once reads the profile path from that process's /proc environ. Popen returns when the child's close-on-exec pipe closes, early in the kernel's exec, but the new environment is readable only once create_elf_tables sets env_end (fs/binfmt_elf.c). Until then the read is empty (fs/proc/base.c), refused, or the parent's, so the lookup falls back to the caller's own $HOME and the assertion fails on /home/<user>/.config/fcitx5/profile, as it did in CI. On a 7.2 kernel, 842 of 2000 reads made right after Popen returned lacked the child's environment, which appeared p50 26 us and p99 44 us later. With the test's VM pinned to one host core, as vCPUs share a core on a busy runner host, the test failed that way in 12 of 150 runs before this change and 0 of 150 after. A real Fcitx owns its bus name long after its exec, so the shell's lookup is unaffected; only the test needs to wait. (cherry picked from commit 79dcccf) * Keep the agent account test off the network agent-account-exec-test pointed mise at all of etc/mise, so the agents were declared lazy tools. Current mise installs a declared lazy tool before running its wrapper, so offline the test failed fetching claude@latest before it reached the fake CLI. Give it only the wrapper declarations. mise also refuses a wrapper whose tool has no binary, so the first-run install cases now call omarchy-agent-account-exec the way mise hands off to it, with the wrapper directory off PATH. The quattro commit also fixed the dropdown test, which v4-5-0 doesn't have yet; that half goes with the backport that brings the test. (cherry picked from commit 0a54d6f) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CY6YBoMt9VUxZ6fJqSXaj1 * Stop a QML fixture's child processes along with its Quickshell The fixture cleanup killed Quickshell and removed its scratch HOME, but the processes Quickshell had started (the agent usage scanner, the plugin directory's inotifywait) outlived it. The scanner could still be writing into home/.cache while rm -rf ran, so cleanup failed with "Directory not empty", and since that rm was the trap's last command, set -e failed a test whose checks had all passed. The watchers were left running against deleted directories after every run. Stop the whole process tree, and retry the removal briefly for a child caught mid-write. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CY6YBoMt9VUxZ6fJqSXaj1 (cherry picked from commit 63fd018) * Stamp the Kimchi test's repeated reply once The pi scanner counts a reply once per id and timestamp, as a real repeated entry carries both. The test built its repeated a-1 reply with two reply() calls, each stamping fixture_now() to the millisecond, so when the clock ticked between them they were two replies and today's minimax-m3 tokens came out doubled (1850 for 925). Under the full suite that happened often enough to fail. Build the entry once and write it twice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CY6YBoMt9VUxZ6fJqSXaj1 (cherry picked from commit 93e3b0a) * Stop a crashed QML fixture's children through its process group Fixture cleanup found Quickshell's children by walking down from a live Quickshell, so once Quickshell had crashed (a compositor disconnect, say) the walk never ran and its children, such as the plugin directory's inotifywait, were left to init. Start each fixture's Quickshell in a process group of its own with setsid and signal the group, which works whether or not its leader is still alive. A second fixture in the same file stops the first the same way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CY6YBoMt9VUxZ6fJqSXaj1 --------- Co-authored-by: Emir Beganović <beganovic.emir@gmail.com> Co-authored-by: David Heinemeier Hansson <david@hey.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
What
With the bar transparent, Omarchy re-sampled the wallpaper with ImageMagick every time anything was created, renamed or removed in
~/.local/state/omarchy, not only when the background or theme changed. Plugins save state there all the time (clipboard history, notifications, toggles, logs), and before #14281 bounded each sample, one plugin saving every 10 seconds held roughly 40% of a core on a 5K display for the whole session, invisible in quickshell's own CPU figure becausemagickis a reaped grandchild.Why
Bar.qmlwatched~/.local/state/omarchy/currentwithFileView { watchChanges: true }. Quickshell'sFileViewalso watches the path's parent directory, and on any event there it emitsfileChangedwhenever the path is not in the watcher's file set. A directory never is, so the watch oncurrentfired for every entry changed in~/.local/state/omarchy.Watching the
current/backgroundlink itself does not work:ln -nsf, whichomarchy-theme-bg-setandomarchy-theme-setuse to repoint it, never reaches aFileViewon the link, because inotify follows it to the old image and the parent-directory fallback only fires when the watched file is missing.Fix
The
FileViewnow watchescurrent/theme. Its parent is thencurrent/, whereomarchy-theme-setswaps the theme directory and both commands repoint the background link, so those still re-sample, while writes besidecurrent/no longer do. It costs no extra process, and a theme switch re-samples even when the new background resolves to the same path as the old one.Cheaper sampling in
omarchy-bar-text-color, which this pull request first carried, is already on quattro through #14281.test/shell.d/runtime-smoke-test.shgains a check against a scratch shell: an atomic write in~/.local/state/omarchymust not runomarchy-bar-text-color, and repointingcurrent/backgroundmust.🤖 Generated by Opus 5.5 in Claude Code. Reviewed by Codex Medium and muse-spark-1.3-contributor (thinking high).