From 72773bc54afd5c8b20ca237b11f8373d0c8bc726 Mon Sep 17 00:00:00 2001 From: astar76 Date: Thu, 12 Nov 2026 07:09:30 -0600 Subject: [PATCH] S016: R1-11 system accent follows the Caelestia scheme On niri with the Caelestia shell the desktop colours live in ~/.local/state/caelestia/scheme.json, while GNOME's accent-color (and the portal) stay at a stale 'red'. system_accent reads the scheme's primary first. smoke.sh isolates XDG_STATE_HOME so runs never see the user's state. Co-Authored-By: Claude Opus 5.5 --- docs/PROGRESS.md | 4 ++++ docs/review/phase1.md | 1 + src/theme.rs | 27 ++++++++++++++++++++++++++- tools/smoke.sh | 2 +- 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/docs/PROGRESS.md b/docs/PROGRESS.md index 7971713..9e60f3f 100644 --- a/docs/PROGRESS.md +++ b/docs/PROGRESS.md @@ -165,9 +165,13 @@ One entry per session, newest last, ≤ 15 lines: done, verified how, not done, pages; `draw` restyles when the active tab's site colour changes (also on Back to the web page). Test added. - Verified: 53 unit tests; `SMOKE_SIZE=1280x1100 tools/smoke.sh tests/smoke/colours.txt` (new, page `pages/theme-colour.html`) all shots as expected; visible run covers site → Settings → Back (taps miss at 772 px). +- System accent on niri + Caelestia: read `~/.local/state/caelestia/scheme.json` primary before kdeglobals and + GNOME's stale `'red'`; test added; smoke.sh now isolates `XDG_STATE_HOME`. Visible shot with a copy of the + user's scheme shows the desktop's pink-purple. Not done: live follow of wallpaper changes (restart needed). - Not seen: the user's exact path, if it was another one; ask them to retry. ## Later +- System accent: watch caelestia scheme.json / the portal `accent-color` and restyle live (R1-11). - Reader mode, split view, translate, real gamepad rumble (D-002: not planned for now). - Packaging and first release (D-001: plan when the user asks). - Shortcut icons: a favicon cache by host (today only open tabs' favicons show); a `scroll` selftest command. diff --git a/docs/review/phase1.md b/docs/review/phase1.md index 3dfa743..6c48870 100644 --- a/docs/review/phase1.md +++ b/docs/review/phase1.md @@ -37,6 +37,7 @@ State tags: `[open]`, `[fixed ]`, `[wontfix: reason]`. Severity: high / - R1-09 [fixed 87299d3] Address bar becomes a wavy progress bar while a page loads: the address pill turns into a Material 3 Expressive wavy (wiggly) progress line that maps the page's load progress; hovering it (or focusing it, or typing) morphs it back to the normal text field; when not loading it's the normal field. Every change between the two states is animated (spring morph, Motion setting respected). Build it as described here; the old browser's loading wave (a line under the pill) is NOT the target. Severity: medium. (user, during S020) → chrome follow-up after S020, before S021. - R1-10 [open] Tab loading indicator: while a tab loads, its favicon spot shows a cookie-shaped (scalloped, M3 Expressive) progress ring, like the original Python Nacre's that the user liked: the stroke draws forward around the cookie outline, then retracts backwards, and keeps repeating while the whole shape spins smoothly; it morphs back into the favicon when loading ends. Motion setting respected (Motion off = static indicator). Here the original IS the reference: `draw_spinner` in `~/Documents/Apps/Nacre/nacre/widgets.py`, used by `tabs.py` (read only). Severity: medium. (user, after S020) → chrome follow-up with R1-09, before S021. - R1-11 [fixed f99500f] Colours can't be changed after the welcome setup: once the user finished nacre://welcome, changing the browser colours (Settings → Appearance colour source / palette / custom) had no visible effect. Reproduce: fresh profile, finish the welcome flow, then change colours in Settings. Severity: high. (user, after S020) → first fix before S021 if quick, else S012. Cause found: an internal page typed into a web tab kept that site's theme-color, which won over palette picks under the Website source; the user's exact welcome path didn't reproduce (welcome + every Appearance control works in smoke). +- R1-11 detail [fixed S016 follow-up] "System accent" differed from the desktop on niri + caelestia-niri: Nacre read kdeglobals `AccentColor` (none there), then GNOME `accent-color` (`'red'`, also what the portal reports: #E62D42), which Caelestia never updates. The desktop's real colours are in `~/.local/state/caelestia/scheme.json` (primary `#e6b6f1`). Nacre now reads that file's `colours.primary` first. Nothing missing on the desktop side; optional: set the GNOME/portal accent too for other apps. Still read once at start: a new wallpaper needs a Nacre restart (Later). - R1-12 [open] YouTube still doesn't open (same as R1-03; reconfirmed after the redesign). Severity: high. → S006. - R1-13 [open] Dark mode: icons on DuckDuckGo (the page opened in the user's test) don't use the right colours. Unclear whether it's the site's own icons under dark mode (prefers-color-scheme / colour-scheme handling) or Nacre's chrome icons; check both. Severity: medium. (user) → S006. - R1-14 [open] Site compatibility pass: "more things for sites to actually work right": a proper user agent (Servo 0.7 can set the UA through its preferences even though it can't add request headers; pick a mainstream Firefox/Chrome-like UA string, check per-site overrides), JavaScript features sites expect, and a general "doctor" pass over common sites (YouTube, Google sign-in, captchas, DuckDuckGo, Reddit, GitHub). Severity: high. (user) → S006/S007; extend S006 with a site-doctor checklist. diff --git a/src/theme.rs b/src/theme.rs index 7e2a5a1..96a5dfd 100644 --- a/src/theme.rs +++ b/src/theme.rs @@ -48,10 +48,19 @@ pub fn to_hex(c: Color32) -> String { format!("#{:02X}{:02X}{:02X}", c.r(), c.g(), c.b()) } -/// The system accent colour: KDE's kdeglobals, else GNOME's accent-color setting. +/// The system accent colour: the Caelestia shell's wallpaper scheme, else KDE's kdeglobals, else GNOME's +/// accent-color setting. pub fn system_accent() -> Option { #[cfg(unix)] { + // Caelestia (niri or KDE) themes the desktop from ~/.local/state/caelestia/scheme.json and leaves the + // GNOME accent at whatever it was. + if let Some(path) = dirs::state_dir().map(|d| d.join("caelestia/scheme.json")) + && let Ok(text) = std::fs::read_to_string(path) + && let Some(c) = caelestia_primary(&text) + { + return Some(c); + } if let Some(path) = dirs::config_dir().map(|d| d.join("kdeglobals")) && let Ok(text) = std::fs::read_to_string(path) { @@ -94,6 +103,13 @@ pub fn system_accent() -> Option { } } +/// The primary colour of a Caelestia `scheme.json` (`{"colours": {"primary": "e6b6f1", ...}}`). +fn caelestia_primary(text: &str) -> Option { + let json: serde_json::Value = serde_json::from_str(text).ok()?; + let hex = json.get("colours")?.get("primary")?.as_str()?; + parse_hex(hex) +} + /// Whether the system prefers dark (used for "System" mode before winit reports a theme). pub fn system_dark(winit_theme: Option) -> bool { match winit_theme { @@ -609,6 +625,15 @@ mod tests { assert!(!output.shapes.is_empty()); } + // R1-11: on niri with the Caelestia shell, "System accent" took GNOME's stale accent instead of the desktop's. + #[test] + fn caelestia_scheme_primary() { + let text = r#"{"name": "dynamic", "mode": "dark", "colours": {"background": "161217", "primary": "e6b6f1"}}"#; + assert_eq!(caelestia_primary(text), Some(Color32::from_rgb(0xE6, 0xB6, 0xF1))); + assert_eq!(caelestia_primary(r#"{"colours": {}}"#), None); + assert_eq!(caelestia_primary("not json"), None); + } + #[test] fn colours() { assert_eq!(parse_hex("#6750A4"), Some(Color32::from_rgb(0x67, 0x50, 0xA4))); diff --git a/tools/smoke.sh b/tools/smoke.sh index e54c4a3..9874561 100755 --- a/tools/smoke.sh +++ b/tools/smoke.sh @@ -82,7 +82,7 @@ env -u WAYLAND_DISPLAY -u DISPLAY -u DBUS_SESSION_BUS_ADDRESS -u NACRE_HOME \ -u http_proxy -u https_proxy -u all_proxy -u HTTP_PROXY -u HTTPS_PROXY -u ALL_PROXY \ "${dispvars[@]}" \ HOME="$home" XDG_CONFIG_HOME="$home/.config" XDG_DATA_HOME="$home/.local/share" \ - XDG_CACHE_HOME="$home/.cache" XDG_RUNTIME_DIR="$runtime" \ + XDG_CACHE_HOME="$home/.cache" XDG_STATE_HOME="$home/.local/state" XDG_RUNTIME_DIR="$runtime" \ RUST_BACKTRACE=1 NACRE_SCRIPT="$out/script.txt" \ timeout -k 10 "${SMOKE_TIMEOUT:-180}" "$bin" >"$out/nacre.log" 2>&1 code=$?