Skip to content

Stop re-sampling the wallpaper for the transparent bar on unrelated state writes - #8307

Merged
dhh merged 6 commits into
omacom:quattrofrom
ryanyogan:bar-text-color-relink-only
Oct 27, 2026
Merged

dhh merged 6 commits into
omacom:quattrofrom
ryanyogan:bar-text-color-relink-only

Conversation

@ryanyogan

@ryanyogan ryanyogan commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

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 because magick is a reaped grandchild.

Why

Bar.qml watched ~/.local/state/omarchy/current with FileView { watchChanges: true }. Quickshell's FileView also watches the path's parent directory, and on any event there it emits fileChanged whenever the path is not in the watcher's file set. A directory never is, so the watch on current fired for every entry changed in ~/.local/state/omarchy.

Watching the current/background link itself does not work: ln -nsf, which omarchy-theme-bg-set and omarchy-theme-set use to repoint it, never reaches a FileView on 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 FileView now watches current/theme. Its parent is then current/, where omarchy-theme-set swaps the theme directory and both commands repoint the background link, so those still re-sample, while writes beside current/ 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.sh gains a check against a scratch shell: an atomic write in ~/.local/state/omarchy must not run omarchy-bar-text-color, and repointing current/background must.

🤖 Generated by Opus 5.5 in Claude Code. Reviewed by Codex Medium and muse-spark-1.3-contributor (thinking high).

…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.
Copilot AI balanced review requested due to automatic review settings August 25, 2026 23: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

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.

Comment thread shell/plugins/bar/Bar.qml Outdated
Process {
id: transparentBackgroundProbe
property bool rerun: false
command: ["readlink", "-f", root.stateHome + "/omarchy/current/background"]
Comment thread shell/plugins/bar/Bar.qml Outdated
Comment on lines +887 to +890
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>
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Sep 28, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

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 quattro into the branch (e050b8b). The branch conflicted with quattro in two places. In bin/omarchy-bar-text-color, quattro had since added the [0] first-frame selector for video backgrounds (#6792); it is kept on your reduced-scale magick call. In test/shell.d/runtime-smoke-test.sh, your wallpaper-sampling checks now run before quattro's replacement-bar probes, which that file wants run last. Nothing else changed.

The bug reproduces, and the fix holds. Tested on a fresh Omarchy VM with the shell running from this branch:

  • runtime-smoke-test.sh with quattro's Bar.qml and sampler: fails with "unrelated writes to the state directory must not re-sample the wallpaper (was 1, now 2)". At this head: 22 passed, 0 failed.
  • bar-text-color-test.sh: 6 passed.
  • Old and new omarchy-bar-text-color picked the same colour in all 60 cases tried: five images (JPEG plasma, horizontal and vertical gradients, WebP, flat PNG) × four bar positions × three screen sizes. Five samples of a 2912x1632 JPEG at 5120x2160 took 1.9s user CPU before and 0.15s after.
  • The full shell suite and ./test/cli have the same failures on this head as on quattro itself (the same failing shell checks, and ./test/cli stopping at "vscode generated theme references current theme file"), so none come from this change.

One narrow gap, not fixed here. Deciding by the resolved path alone misses a wallpaper change when the path string stays the same. omarchy-theme-set points the link at current/theme/backgrounds/<name> and replaces current/theme in place. So if you switch between two themes that both have omarchy.webp selected, the resolved path is identical even though the image changed. A theme change usually also changes the bar's text colour, which triggers its own re-sample, so this only bites when both themes share that colour. Adding the file's inode to what is compared would close it.

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 magick line to add memory limits and a timeout, so whichever lands second will need a small rebase.

Waiting on the maintainer. It is labelled verified but not ready, because no second opinion ran and the suites are not green on quattro itself.

omarchybot and others added 3 commits October 27, 2026 14:04
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>
@greptile-apps

greptile-apps Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge; no actionable issues were found.

Summary

Narrows the transparent bar’s file watch to avoid wallpaper sampling after unrelated state writes.

  • The transparent bar refreshes for background changes, not 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

@omarchybot

Copy link
Copy Markdown
Collaborator

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 ~/.local/state/omarchy (tmp + mv, touch, rm) ran omarchy-bar-text-color six times. A standalone quickshell -p probe confirmed both of your claims about Quickshell 0.3.2: a FileView on current fires for every entry changed in the parent directory, and a FileView on current/background never fires when ln -nsf or omarchy-theme-bg-set repoints the link.

What I pushed (b443388):

  • Merged quattro in. bin/omarchy-bar-text-color takes quattro's version: Bound wallpaper resource use when sampling bar colors #14281 already bounds the sample with a 1920px canvas, a JPEG size hint, -scale and memory, time and thread caps, so the cheaper-sampling half and its two tests are dropped.
  • Replaced the readlink probe with a one-line path change: the FileView now watches current/theme. Quickshell watches the path's parent too, so the parent becomes current/. That is where omarchy-theme-set swaps the theme directory and both commands repoint background, while writes beside current/ no longer reach the bar. This spawns no extra process. It also still re-samples on a theme switch whose new background resolves to the same path as the old one, which comparing readlink -f output would skip.
  • Rewrote the test in test/shell.d/runtime-smoke-test.sh against quattro's scratch-shell harness. An atomic write in ~/.local/state/omarchy must not run the helper, and repointing current/background must. It fails on quattro ("unrelated state writes re-sample the wallpaper"). It passes on this branch. It also fails if the path is changed to current/background ("repointing the background re-samples the wallpaper"), so both halves have something to catch. It sits early in the file because the file already fails later on quattro, at "keepLoaded fixture service IPC responds", with or without this change.

Checked on the worker with this branch linked into the running session: unrelated writes ran the helper zero times. omarchy-theme-bg-set, omarchy-theme-bg-next and omarchy-theme-set each still re-sampled. The bar text went from dark on a light Catppuccin Latte wallpaper to light after switching to a dark one, confirmed by a cropped capture of the bar. Also passing there: bar-text-color-test.sh, bar-test.sh, plugin-auth-boundary-test.sh, shell-idle-spawn-test.sh, bar-widget-contract-test.sh, background-pending-theme-test.sh, theme-set-retint-order-test.sh and ./test/cli.

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 current/theme (omarchy-theme-set-glass's sed -i) also re-sample, so I reworded the test so it no longer claims that only swaps do. Both noted that, unlike the old parent watch, this one cannot recover if current/ itself is missing at shell start or replaced while the shell runs. Nothing in bin/, install/ or migrations/ does either, and install runs omarchy-theme-set before the first session, so I left it. Their agreement with my own reading is not independent, since they could see this session's notes.

Related: #14220 merges cleanly on top and keeps this watch as its fallback. #14148 gates this same FileView's handler. Its Bar.qml change merges cleanly with this branch, and its test conflicts already exist against quattro alone.

This is waiting on the maintainer.

@dhh
dhh merged commit bc220e7 into omacom:quattro Oct 27, 2026
2 checks passed
dhh pushed a commit that referenced this pull request Oct 27, 2026
…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>
emirb added a commit that referenced this pull request Oct 28, 2026
…#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.
katrushenkov pushed a commit to katrushenkov/omarchy that referenced this pull request Oct 28, 2026
…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.
dhh added a commit that referenced this pull request Nov 2, 2026
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants