Skip to content

Remember the transparent bar's sampled text color per wallpaper - #16987

Open
JamesForan wants to merge 2 commits into
omacom:quattrofrom
JamesForan:bar-text-color-cache
Open

JamesForan wants to merge 2 commits into
omacom:quattrofrom
JamesForan:bar-text-color-cache

Conversation

@JamesForan

@JamesForan JamesForan commented Oct 29, 2026 •

Copy link
Copy Markdown

What

Switching the bar to transparent takes about half a second before anything changes on screen, and the same pause follows a bar move or a theme change while transparent. The bar's transparentForegroundTimer settles for 120ms and then runs omarchy-bar-text-color, which resizes the wallpaper through ImageMagick on every call to pick a legible text color. On a 4K wallpaper that is ~300ms (measured on the current quattro script; ~400ms on the 4.0.6 release) with nothing visible happening, so a keybinding that toggles transparency reads as a dead key press.

How

The chosen color only depends on the wallpaper, the screen size, the bar edge and size, and the text/background color pair, so omarchy-bar-text-color now remembers it under ${XDG_CACHE_HOME:-$HOME/.cache}/omarchy/bar-text-color/, keyed by those inputs plus the wallpaper file's size and mtime. A later call with the same inputs answers from the file without ImageMagick (~35ms, almost all of it bash startup and the hyprctl screen lookup). A new wallpaper, theme, bar edge, bar size or screen is a new key and gets sampled once.

  • Only a finished sample is remembered. A failed or timed-out sample still falls back to the configured text color and is retried on the next call, so a transient ImageMagick failure cannot stick.
  • Written atomically (mktemp + mv) so a concurrent call never reads a partial file; a corrupt entry is ignored and re-sampled.
  • Entries older than 30 days are swept on a miss. They are a few bytes each.
  • The sampling itself is unchanged, including the resource bounds from Bound wallpaper resource use when sampling bar colors #14281.

Tests

test/shell.d/bar-text-color-test.sh:

  • A repeated sample runs ImageMagick once; the second call returns the same color without it.
  • A wallpaper file with a new mtime is sampled again.
  • A sample that fell back is not remembered: the retry switches to the contrasting color once ImageMagick finishes.
  • An unwritable and an uncreatable cache directory still answer with the sampled color (remembering is best-effort and happens after the answer is printed).
  • The suite now points XDG_CACHE_HOME at its temp dir, and the cases that re-sample the same wallpaper through different ImageMagick stubs each use their own, so nothing leaks into or out of the real cache.

./test/shell on this machine: 391 of 405 files pass, bar-text-color-test.sh among them (14 cases). The 14 failing files (agent-account, battery-status, brave-widevine, hermes-cli, keybindings-menu, menu-plugin, omarchy-kernel, remote-session-service, screenrecording-wf-audio, sleep-lock, system-power, update-restart-kernel, pacman-templates, shell-idle-spawn) are unrelated to the bar; 12 of them fail identically on unmodified quattro here, and the other two pass on this branch when run on their own, so they were order or timing sensitive in the full run. Timed with the script from this branch against a real wallpaper and a 3440x1440 screen: first call ~300ms, every later call ~35ms.

🤖 Generated with Claude Code

Every switch to a transparent bar, bar move or theme change ran ImageMagick
over the wallpaper again to pick a legible text color, a few hundred
milliseconds in which nothing visible happens, so the toggle reads as a dead
key press. The answer only depends on the wallpaper, the screen, the bar edge
and size, and the color pair, so remember it under XDG_CACHE_HOME keyed by
those and the wallpaper file's size and mtime, and answer from there on later
calls. Only a finished sample is remembered; a failed or timed-out one falls
back as before and is retried next time.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge; the previous cache-error issue is fixed and no new blocking issue was found.

Summary

Remembers the transparent bar’s sampled text color for each wallpaper and set of display inputs.

  • The bar reuses its sampled text color when the wallpaper and settings match.

The previous finding is fixed. No new actionable issues were found in the follow-up changes. Tests were not run during this review.

Reviews (2) · Last reviewed commit: "Answer before remembering the sampled ba..." · Reviewed by Greptile

Comment thread bin/omarchy-bar-text-color Resolved
Remembering is best-effort, so print the colour first and let a cache sweep,
temp file or rename that fails leave the answer untouched; under set -e any of
them could otherwise exit the script before the caller got its colour.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@omarchybot omarchybot added the enhancement New feature or request label Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants