Skip to content

feat(theme): follow the system light/dark mode - #2094

Merged
l0gicgate merged 5 commits into
lgse:mainfrom
polycatenane:feat/follow-system-dark-mode
Nov 8, 2026
Merged

l0gicgate merged 5 commits into
lgse:mainfrom
polycatenane:feat/follow-system-dark-mode

Conversation

@polycatenane

@polycatenane polycatenane commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Add a "Follow system light/dark mode" switch that tracks the desktop's light/dark preference (the color-scheme key of the org.gnome.desktop.interface) and switches between the light and dark versions of a curated Strata theme family. Strata keeps using its own palettes; it does not adopt the desktop's GTK theme, icons, or accent color.

Description

Adds a Follow system light/dark mode switch under Settings → Appearance. When it is on, Strata uses the light or dark version of the chosen Strata theme to match the desktop's light/dark mode, and switches live when that mode changes. The preference is read (never written) from the color-scheme key of org.gnome.desktop.interface: prefer-dark uses the dark version; default and prefer-light use the light one.

Only the light/dark preference is followed. Strata keeps its own theme palettes and does not load the desktop's GTK theme, icon theme, or accent color.

  • 28 bundled theme families have light/dark pairs (for example One Dark/One Light, Catppuccin Mocha/Latte, Rosé Pine/Dawn, Solarized). Themes without a pair keep the same palette in both modes.
  • The saved theme is the family anchor. Picking either version of a pair in the library changes the family and leaves the switch on. Settings shows the palette in use as Current theme and checks its card.
  • A custom theme that overrides a paired bundled theme's ID joins that pair.
  • Changes apply live to the GTK light/dark base variant, Strata colors, icons, documents, source highlighting, previews, and open settings pages.
  • Follow system light/dark mode and Follow Omarchy are exclusive; turning one on turns the other off.
  • If the color-scheme setting is unavailable, the switch is hidden and a saved mode = "system" falls back to "theme" at startup.
  • New strings are translated into all 13 supported languages. The README, docs/themes.md, and docs/preferences.md document the behavior.

Visual evidence

image

The change adds one switch row to Settings → Appearance and changes which Strata theme is applied when the desktop's light/dark mode changes.

How to test

  1. Open Settings → Appearance and turn on Follow system light/dark mode.
  2. Select One Dark in the theme library.
  3. Run gsettings set org.gnome.desktop.interface color-scheme prefer-dark. Strata uses One Dark.
  4. Run gsettings set org.gnome.desktop.interface color-scheme default (or prefer-light). Strata switches to One Light without a restart.
  5. Pick Catppuccin Latte while the switch is on. The switch stays on, and Strata uses Catppuccin Mocha or Latte to match the current mode.
  6. Pick Tokyo Night, which has no pair, and change the mode again. The palette stays the same.
  7. Turn on Follow Omarchy (if available). Follow system light/dark mode turns off.
  8. Restart Strata with the switch on. It starts in the palette for the current mode.

Expected result: Strata's colors switch between the light and dark versions of the chosen Strata theme as the desktop's light/dark mode changes, and Strata's own themes stay in use throughout.

Related issue

Closes #1812

Add a "Follow system light/dark mode" switch that tracks the desktop's
light/dark preference (the color-scheme key of the
org.gnome.desktop.interface) and switches between the light and dark
versions of a curated Strata theme family. Strata keeps using its own
palettes; it does not adopt the desktop's GTK theme, icons, or accent
color.
only_gnome_prefer_dark_uses_night_appearance repeated the string
comparison it called, and system_mode_uses_custom_overrides_by_stable_id
re-checked the existing custom theme merge plus the pair lookup. The live
GNOME test, the curated pairs test and the catalog merge test cover both.
While following the system light/dark mode, current_tokens still read the
saved family anchor, so PDF text selection and the Add a theme editor used
the other palette from the one on screen. Resolve it through the effective
theme ID and drop the duplicate lookup.
Restore the code health the light/dark following lowered: group the GNOME
settings and dark flag into SystemAppearance with its ThemeManager methods,
derive Omarchy availability inside ThemeManager::new, replace the mode
validity condition with a match, and extract the current theme row and
theme source switches from theme_page.
@l0gicgate

Copy link
Copy Markdown
Contributor

Review and cleanup

Merged main at 4f4dc17c1 (clean, no conflicts).

Review against the description and #1812. Every claim checks out: the switch reads (never writes) org.gnome.desktop.interface color-scheme, prefer-dark picks the dark side and anything else the light side, picking either side of a pair keeps following on, unpaired and custom IDs resolve to themselves, the two follow switches are mutually exclusive through the shared bind_theme_switch guard, Current theme and the checked card follow live changes, a saved mode = "system" falls back to "theme" without the schema, and all 13 catalogs carry the new strings. The schema is present in the pinned test image (via xdg-desktop-portal-gtk → gsettings-desktop-schemas), so the expects in the new tests hold in CI. There were no review comments to reconcile.

Fixes pushed

  • b114d4578 fix(theme): resolve current tokens to the followed light/dark theme. current_tokens still read the saved family anchor, so PDF text selection (preview/pdf/pages.rs) and the Add a theme editor's starting palette used the other side of the pair from the one on screen. It now resolves through effective_theme_id, replacing the duplicate effective_tokens; the live GNOME test asserts it.
  • 1f352ca3a refactor(theme): keep system appearance state in its own module. The PR lowered CodeScene health (theme.rs 10.0 → 8.54, preferences.rs 10.0 → 9.09, settings/theme.rs 7.86 → 7.8). The GNOME settings and dark flag are now one SystemAppearance value with its ThemeManager methods in system_appearance.rs, ThemeManager::new derives Omarchy availability itself, the mode check is a match, and the current-theme row and source-switch bindings are extracted from theme_page. Scores are now 10.0, 10.0 and 8.04; every other touched file is 10.0 or unchanged from main.

Tests removed

  • ui::theme::tests::system_appearance::only_gnome_prefer_dark_uses_night_appearance: repeated the == "prefer-dark" comparison; coverage owner: system_appearance_applies_at_startup_and_follows_gnome_live (drives prefer-dark, prefer-light, and default).
  • ui::theme::tests::system_appearance::system_mode_uses_custom_overrides_by_stable_id: re-checked merge_builtin_and_custom_themes plus the pair lookup without touching ThemeManager; coverage owners: curated_system_theme_pairs_resolve_in_both_directions and the catalog merge test in ui::theme::tests::catalog.

Validation

  • ./scripts/test-headless.py -- ui::theme:: ui::settings:: ui::preferences::tests::preferences ui::table_view::selection i18n:: preview::pdf: 202 passed
  • ./scripts/quality.sh fmt, ./scripts/quality.sh clippy: clean
  • ./scripts/code-health.sh --changed: no file below main
  • Not run: qa.sh (no scenario covers the Appearance page)

Follow-ups outside this PR

  • The switch reads GNOME's color-scheme key directly. Desktops that publish their preference only through the XDG portal (org.freedesktop.appearance color-scheme, e.g. KDE) show the switch, but it has no effect there. Reading the portal setting would cover them.

CI: all checks green on 1f352ca3a.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Day/Night Theme Switching

2 participants