Skip to content

feat: follow the system accent color - #363

Merged
Hakanbaban53 merged 3 commits into
Zarestia-Dev:masterfrom
repires:feat/system-accent-color
Nov 25, 2026
Merged

Hakanbaban53 merged 3 commits into
Zarestia-Dev:masterfrom
repires:feat/system-accent-color

Conversation

@repires

@repires repires commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Part of #37 (the GTK accent colour item).

What

  • New command get_system_accent_color returns the system accent as #rrggbb, or null when there is none. The first call starts a watcher that emits SYSTEM_ACCENT_COLOR_CHANGED. The code lives in native/accent.rs:
    • Linux: org.freedesktop.appearance / accent-color from the XDG settings portal (GNOME 47+, KDE Plasma 6), using native::portal like the button layout. The portal reports "no accent" as values outside 0–1.
    • Windows: UISettings.GetColorValue(UIColorType::Accent), following ColorValuesChanged.
    • macOS: NSColor.controlAccentColor converted to sRGB, following NSSystemColorsDidChangeNotification. "Multicolor" reports the system blue.
    • Repeated notifications with the same colour are dropped (GNOME sends each change twice; Windows reports every colour change).
  • WindowService (Linux, Windows and macOS) sets data-system-accent and --system-accent-* on <html>. custom-theme.scss then uses the accent for both the primary and the accent roles: --primary-color*, --accent-color*, --accent-bg-color, --accent-fg-color and the Material --mat-sys-primary* and --mat-sys-tertiary* tokens. Without the attribute (setting off, or no system accent), primary stays green and accent stays blue.
  • Readable text: like libadwaita, text and icons keep the accent's hue but are clamped in OKLab to lightness ≤ 0.5 on light backgrounds and ≥ 0.85 on dark ones. Text on an accent fill is white, or dark when white would fall under 3:1 contrast (Windows and macOS allow any colour). A new --primary-fg-color carries that; on the default green it stays dark, as before.
  • Preferences > General > System Accent Color (desktop builds, on by default) turns it off.
  • The command and event are allowed while the vault is locked (LOCKED_NATIVE_COMMANDS, PUBLIC_EVENTS), like the theme and button layout, since they only affect how the window looks.
  • Label and description in all 11 languages.

Tests

  • Rust: colour conversion, the portal value parser (plain, nested in a variant, out of range, wrong type), the new setting's presence and default, and the event reaching a locked interface. cargo fmt and clippy -D warnings for the Linux desktop build; the accent module also passes clippy -D warnings for x86_64-pc-windows-msvc and aarch64-apple-darwin.
  • Frontend: accentPalette matches libadwaita's derived colours, picks the text colour on the fill, and rejects malformed input. WindowService applies the accent only while the setting is on, on Linux, Windows and macOS but not elsewhere, follows changes, removes the accent when the system has none, and keeps a change that arrives before the first read. ESLint, Prettier, ng build and audit:i18n are clean.

Tested on Windows and macOS in VMs (videos in the conversation): the app recolours right away when the accent changes. Not yet seen on a real GNOME or KDE session; changing the accent in Settings > Appearance should do the same there.

@repires

repires commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

The Frontend failure here isn't from this PR. It's the axe check for the window controls from #357, which breaks on master too since it met #353's buttonLayout. #364 fixes it; once that's in I'll rebase this onto master.

@repires

repires commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto master. Two changes besides that:

Full suite, ng build and audit:i18n pass. Rust fmt, clippy and the settings and window tests pass on Fedora.

@repires
repires force-pushed the feat/system-accent-color branch from b457b36 to 28349f4 Compare November 19, 2026 20:25
@Hakanbaban53

Hakanbaban53 commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

This looks good, but I'd like to make a few changes to improve it.

Currently, the app uses a fixed primary color, and these colors affect quite a lot of the UI. I'd actually like to use the system's accent color as the app's primary color. I tested this approach, and it looks much better than keeping a fixed color.

We should also consider Windows and macOS, as they have system accent colors as well. Could we make this work across those platforms too?

I can test it on Linux. If you're unable to test it on Windows or macOS, I can test it myself using VMs.

Thanks for working on this!

Uses the system accent as the app's primary colour on Linux (XDG
settings portal accent-color, GNOME 47 and later, KDE Plasma 6),
Windows (UISettings accent) and macOS (NSColor.controlAccentColor),
and follows its changes. Text keeps the accent's hue at OKLab
lightness at most 0.5 on light and at least 0.85 on dark backgrounds,
as libadwaita does; text on an accent fill is white unless the accent
is too light for it. Preferences > General > System Accent Color turns
it off. Systems without an accent keep the green (Zarestia-Dev#37).
@repires
repires force-pushed the feat/system-accent-color branch from 28349f4 to 3f80f4a Compare November 24, 2026 23:09
@repires repires changed the title feat(linux): follow the desktop's accent color feat: follow the system accent color Nov 24, 2026
@repires

repires commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Thanks! Done in 3f80f4a (rebased onto master as well).

  • Primary colour: the system accent now replaces the green primary (--primary-color, --primary-color-rgb, --primary-color-text and the --mat-sys-primary* tokens) instead of the blue accent. Text on a primary fill is white, or dark when the accent is too light for white (under 3:1 contrast), which matters on Windows and macOS where any colour can be picked. The primary tone reads that through a new --primary-fg-color, so the default green keeps its dark text.
  • Windows: UISettings.GetColorValue(Accent), following ColorValuesChanged.
  • macOS: NSColor.controlAccentColor in sRGB, following NSSystemColorsDidChangeNotification. "Multicolor" reports the system blue.
  • The Linux portal code moved with them into native/accent.rs. The setting now exists on all three, and its description says it replaces the default green.

The Windows and macOS code passes clippy -D warnings for both targets, but I couldn't run it, so a check in your VMs would be very welcome: changing the accent in Settings > Personalization > Colors (Windows) or System Settings > Appearance (macOS) should recolour the app right away.

One question: with a blue system accent (the default on GNOME, Windows and macOS), primary now looks the same as the blue accent role (serve, some highlights). Is that fine, or would you like the accent role to change while a system accent is in use?

The workspace clippy config disallows std::mem::forget. Windows keeps
its UISettings in a static; macOS gives up the observer token with
Retained::into_raw.
@Hakanbaban53

Copy link
Copy Markdown
Collaborator

Thanks for the quick turnaround, this looks great!

On your question: yes, I'd like the accent role to change too. While a system accent is in use, it should behave like primary and follow the system accent. So when the setting is on, both primary and accent use the system color, and when it's off (or the system reports no accent), nothing changes and the current green primary and blue accent stay as they are.

I also tested this on Windows and macOS in VMs, and the app recolours right away when the accent is changed in both. Videos below:

Windows:

Screencast.From.2026-11-25.07-50-04.mp4

MacOS

Screencast.From.2026-11-25.07-56-35.mp4

Thanks again for working on this!

While a system accent is in use, the blue accent role follows it like
primary does. With the setting off, or no system accent, primary stays
green and accent stays blue.
@repires

repires commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for testing it on both, and for the videos!

Done in ea62a1a: while a system accent is in use, the accent role follows it too (--accent-color*, --accent-bg-color, --accent-fg-color and the Material tertiary tokens), with the same derived text colours and the same white-or-dark text on fills as primary. With the setting off, or when the system reports no accent, primary stays green and accent stays blue. The setting's description now says it replaces the default green and blue, in all 11 languages.

@Hakanbaban53

Copy link
Copy Markdown
Collaborator

Thanks for the updates! I tested the latest changes and it looks much better now. The system accent works well as the primary color, and the Windows and macOS videos above confirm the recolouring works there too.

Merging now. Thanks again for the great work on this!

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.

2 participants