Skip to content

fix(sensors): keep text contrast against the real background - #5

Open
perlowja wants to merge 1 commit into
singularityos-lab:mainfrom
perlowja:fix/sensors-text-contrast
Open

perlowja wants to merge 1 commit into
singularityos-lab:mainfrom
perlowja:fix/sensors-text-contrast

Conversation

@perlowja

Copy link
Copy Markdown

The sensors chip colors each metric from theme tokens without looking at what is behind it, and the popover dims values with dim-label opacity. On a translucent panel over a bright wallpaper, or a light theme over a dark surface, the text is close to invisible. Measured with the WCAG formula: red on sky blue 1.7:1, green on sky blue 1.4:1, green on a light panel 1.8:1, dim value on a light popover 3.8:1.

Change

  • sensors/contrast.vala: WCAG luminance and contrast math, lightness shifting that keeps the theme hue, a muted tone, a median helper.
  • The chip and popover sample the pixels around themselves and derive neutral, muted, ok, warning, critical and accent colors at 7:1 where possible, 4.5:1 minimum. A translucent surface gets its own backing.
  • Warning and critical also differ by glyph and weight, not hue alone.
  • Re-evaluated on theme, dark-preference and color-scheme changes, panel redraw (150 ms debounce) and popover open. No polling.
  • Only GTK4 and libsingularity. One concern.

Before / after (dark, light):

before after
before dark after dark
before light after light

Verification

  • Commit 8a495f6 on current main (d255d47) with libsingularity b454931, shell 3b72f26 and desktop master 5c75e56, Debian forky arm64 container: meson setup && ninja 784/784 targets, meson test 25/25 pass, including sensors-contrast (7 cases over 10 backgrounds; neutral, muted and semantic colors asserted at 4.5:1 or better, white and black at 7:1).
  • Two x86_64 laptops (AMD Navi14, GTK 4.22, labwc): dark and light theme, live theme switch without restart. Also run on an aarch64 board (dark and light chip, dark popover).

Not verified

  • Warning and critical states were only exercised by the unit test; the test machines never reached those readings.
  • A translucent panel cannot see the wallpaper; the backing follows the theme background polarity.
  • This touches the same file as feat(sensors): DPI-aware column density, bordered sections #2; I will rebase whichever lands second.

AI assistance: disclosed

The chip colored its markup from theme severity tokens regardless of
what it rendered on, and the popover dimmed values with opacity, so
text became unreadable on light, translucent or mismatched panels.

Sample the pixels around the chip and the popover content, then derive
neutral, muted and severity colors that reach WCAG 7:1 (4.5:1 minimum)
by shifting lightness only. A translucent surface gets its own backing.
Warning and critical also differ by glyph and weight. Re-evaluated on
theme, dark-preference and panel redraw signals. The contrast math is
in contrast.vala with a meson test.

Assisted-by: Claude Code:claude-sonnet-5-5
AI-Scope: Drafted the contrast math, sampling and CSS wiring from a description of the bug.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant