Skip to content

Keep the transparent bar's text colour in step with theme switches - #14148

Open
dt-lindberg wants to merge 3 commits into
omacom:quattrofrom
dt-lindberg:fix/transparent-bar-stale-text-color
Open

dt-lindberg wants to merge 3 commits into
omacom:quattrofrom
dt-lindberg:fix/transparent-bar-stale-text-color

Conversation

@dt-lindberg

@dt-lindberg dt-lindberg commented Oct 3, 2026 •

Copy link
Copy Markdown

Fixes #10289. Independent of #14220, but the two conflict in Bar.qml, so I'll rebase whichever lands second.

With a transparent bar, switching theme can leave the bar with the previous theme's text colour. Switching Gruvbox → Rose Pine → Gruvbox, with a few seconds on Rose Pine, leaves Rose Pine's dark purple text on Gruvbox's dark wallpaper. The first switch goes wrong too, less visibly: Gruvbox's light text on Rose Pine's light wallpaper.

Toggling transparency off and on fixes it until the next theme switch.

Screenshots

Same slow round trip (Gruvbox → Rose Pine, wait 5 s → Gruvbox), bar at the top.

Before

Rose Pine, with Gruvbox's light text left over:
rose-pine-before

Back on Gruvbox, with Rose Pine's purple text left over:
gruvbox-before

After

Rose Pine:
rose-pine-after

Gruvbox:
gruvbox-after

Cause

Bar.qml asked omarchy-bar-text-color for a new colour from two places:

  1. A FileView on ~/.local/state/omarchy/current. It fires as soon as omarchy-theme-set creates its next-theme staging folder there, before the new palette or wallpaper reach the shell. That sample runs with the previous theme's colours and wallpaper.
  2. The colour watchers (onThemeForegroundChanged and friends), which fire when the background plugin applies the new palette at the start of the reveal.

The script takes about 0.4–0.7 s. When (2) lands while (1) is still running, refreshTransparentForeground() returns early because the process is busy, and nothing retries. The stale answer from (1) then sticks.

Whether (2) lands inside that window depends on load, which is why it shows up after staying on a theme for a few seconds but not on a quick round trip. A log of each sample's arguments shows it directly:

16:09:45.749  theme set gruvbox
16:09:45.893  START  top 26 #575279 #faf4ed     ← Rose Pine colours
16:09:46.033  theme.name → gruvbox
16:09:46.137  background → Gruvbox wallpaper
16:09:46.572  END    (no further sample)

Fix

  • Background.qml exposes appliedBackground: the wallpaper that goes with the palette on screen. A plain wallpaper change sets it straight away; a theme switch sets it inside applyPendingTheme(), in the same step as the new colours.
  • Bar.qml samples when appliedBackground changes, passing it as --background, so the script samples the wallpaper the shell is showing rather than whatever the link points at mid-switch. The colour watchers stay; on a theme switch they fire in the same step as appliedBackground, so the 120 ms timer folds them into one sample.
  • A sample requested while one is running is no longer dropped. The running sample's answer is discarded and the script runs again when it exits.
  • The state-directory FileView now only acts when the background plugin has no appliedBackground: no background plugin, or one cloned before this change. Those setups keep re-sampling on wallpaper-only changes as before, and the rerun above still corrects the early sample on a theme switch.

Testing

  • New source checks in test/shell.d/bar-test.sh and test/shell.d/background-test.sh. Both fail without the change and pass with it.

  • Live, with this change applied to the installed 4.0.4 shell (plus the services property from quattro's shell.qml, which 4.0.4 lacks) and every sample logged:

    Scenario Samples per change Result
    Gruvbox → Rose Pine → Gruvbox, 5 s apart 1, new colours and wallpaper Correct in both themes
    Same round trip, 1 s apart 1 Correct
    omarchy theme bg next 1 Correct
    Two bg next 0.25 s apart 2: the second waits, then runs Correct for the last wallpaper
    Bar on the left, theme round trip 1 (left 28) Correct
    Old Background.qml (simulated pre-change clone), round trip + bg next 2–3: early sample discarded, rerun with new colours Correct
  • ./test/all: the remaining failures are unrelated. They fail the same way on quattro or need a local omarchy-pkgs checkout.

System

  • Omarchy 4.0.4-1 (branch based on quattro at 393a43d)
  • Kernel 7.2.5-3-omarchy, Hyprland v0.56.2, Quickshell 0.3.1, ImageMagick 7.1.2-31
  • HP Pavilion Laptop 15-eg0xxx: Intel Core i7-1165G7, Intel Iris Xe Graphics
  • Display: eDP-1, 1920×1080 at 60 Hz, scale 1.25

🤖 Generated with Claude Code

@dt-lindberg
dt-lindberg marked this pull request as ready for review October 3, 2026 15:22
@greptile-apps

greptile-apps Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

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

Summary

Keeps transparent bar text in step with theme and wallpaper changes.

  • The transparent bar samples text against the wallpaper now on screen.

No new actionable issues were found. Runtime and visual checks were not performed during this review.

Diagram

sequenceDiagram
  participant Background
  participant Bar
  participant Sampler
  Background->>Background: Apply palette and appliedBackground
  Background->>Bar: Notify changed inputs
  Bar->>Bar: Debounce refresh
  alt Sampler is idle
    Bar->>Sampler: Sample current colors and wallpaper
    Sampler-->>Bar: Set text color
  else Sampler is running
    Bar->>Bar: Queue replacement and block old output
    Sampler-->>Bar: Exit
    Bar->>Sampler: Sample latest inputs
    Sampler-->>Bar: Set text color
  end
Loading

Reviews (4) · Last reviewed commit: "Check the whole bar sample exit handler,..." · Reviewed by Greptile

Comment thread shell/plugins/bar/Bar.qml Resolved
Comment thread test/shell.d/bar-test.sh Resolved
@jandrusk

jandrusk commented Oct 6, 2026

Copy link
Copy Markdown

For reviewers: #13914 (Oct 1) also fixes the dropped transparent-bar sample by queueing a rerun when a request lands mid-sample and discarding the stale answer. This PR does that and also adds appliedBackground to gate the sample on the palette actually on screen. It would help to say whether this supersedes #13914, so only one of them gets reviewed. (#14220 conflicts in Bar.qml too, as you noted.)

@omarchybot

Copy link
Copy Markdown
Collaborator

I read this against current quattro (246f33a). The bug it fixes is still there: refreshTransparentForeground() in shell/plugins/bar/Bar.qml still returns early while a sample is running, and the FileView on ~/.local/state/omarchy/current still schedules a sample as soon as the theme switch begins. I read it as a bug fix, but the second opinion (Codex Medium) could not check that classification because its review budget for today is used up. So no label went on and nothing ran on a worker. It will be classified again on a later pass.

Two things for whoever picks this up next. First, the branch no longer merges cleanly into quattro, which has changed a lot in Bar.qml and Background.qml since 393a43d. Second, #13914 is older and fixes the same dropped request: it queues a rerun and discards the stale answer. This PR does that too, and adds appliedBackground so a theme switch is sampled once, against the wallpaper the shell has applied. Which of the two lands is the maintainer's call. This PR waits on that decision and on the classification being checked.

The bar watched ~/.local/state/omarchy/current, which fires when
omarchy-theme-set starts staging, before the new colors or wallpaper
reach the shell. That sample ran with the previous theme's colors, and
the request the new palette made while it ran was dropped, so the bar
kept the previous theme's text color.

The background plugin now exposes appliedBackground, moved in the same
step as a theme's colors, and the bar samples against it. A request
made while a sample runs is rerun when that sample exits. Without a
background plugin that exposes appliedBackground, such as one cloned
before this change, the bar still re-samples on state directory
changes.
A process's output can arrive after its exit signal, so clearing the
block on exit could briefly apply the outdated answer before the
replacement sample ran.
The assertions matched onExited only as a one-line handler, so an
equivalent block-bodied handler failed them, and one that cleared the
block on a later line passed.
@dt-lindberg
dt-lindberg force-pushed the fix/transparent-bar-stale-text-color branch from 61ebdf0 to 2808d7c Compare October 19, 2026 13:34
@omarchybot omarchybot added the bug Something isn't working label Oct 21, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

I reviewed this again at 2808d7c, which now merges cleanly into quattro. It is a bug fix: Codex Medium and I classified it separately and both said so, and it carries the bug label now. It fixes the cause in #10289. refreshTransparentForeground() no longer drops a request that arrives while a sample is running, and appliedBackground makes the theme-switch sample use the new palette together with the wallpaper the shell has actually applied.

#13914 is older and fixes the same cause in a different way. When a new request arrives, it invalidates the running sample through a request serial, and it retries after that sample exits. I compared the two by reading the source, and asked Codex Medium the same question without giving it my answer. We both concluded that #13914 should be the one to land: nothing in it misses a case this PR handles. In #13914, a sample started before omarchy-theme-set moves the current/background link gets discarded when the link changes, because the state-directory watcher bumps the serial, so that sample's answer never reaches the bar. #13914 also re-samples when the bar size changes, and this PR does not. Codex also pointed out one gap here, which I checked. Because this PR marks a sample stale only when the 120 ms timer fires, an old sample that finishes inside that window can still apply its colour briefly, until the replacement sample corrects it.

What this PR adds on top of #13914 is efficiency: one sample per theme switch, against the applied wallpaper, where #13914 needs a rerun or two. That makes no visible difference, since #13914 already discards every stale answer. It also touches Background.qml, which #14220 reworks heavily. So I have not asked for it to be folded into #13914.

Nothing ran on a worker: verifying a fix that is not the one going forward would spend a worker for nothing. Which fix lands is the maintainer's decision, and this PR waits on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Transparent bar keeps the previous theme's text colour: the refresh request is dropped while a sample is in flight

3 participants