Repository navigation
Remember the transparent bar's sampled text color per wallpaper - #16987
Open
JamesForan wants to merge 2 commits into
Open
JamesForan wants to merge 2 commits into
JamesForan wants to merge 2 commits into
Conversation
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>
Contributor
[Low impact] The PR appears safe to merge; the previous cache-error issue is fixed and no new blocking issue was found. SummaryRemembers the transparent bar’s sampled text color for each wallpaper and set of display inputs.
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 |
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
transparentForegroundTimersettles for 120ms and then runsomarchy-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 currentquattroscript; ~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-colornow 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 thehyprctlscreen lookup). A new wallpaper, theme, bar edge, bar size or screen is a new key and gets sampled once.mktemp+mv) so a concurrent call never reads a partial file; a corrupt entry is ignored and re-sampled.Tests
test/shell.d/bar-text-color-test.sh:XDG_CACHE_HOMEat 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/shellon this machine: 391 of 405 files pass,bar-text-color-test.shamong 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 unmodifiedquattrohere, 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