Repository navigation
feat: follow the system accent color - #363
Conversation
|
Rebased onto master. Two changes besides that:
Full suite, |
b457b36 to
28349f4
Compare
|
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).
28349f4 to
3f80f4a
Compare
|
Thanks! Done in 3f80f4a (rebased onto master as well).
The Windows and macOS code passes clippy 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.
|
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.mp4MacOS Screencast.From.2026-11-25.07-56-35.mp4Thanks 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.
|
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 ( |
|
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! |
Part of #37 (the GTK accent colour item).
What
get_system_accent_colorreturns the system accent as#rrggbb, or null when there is none. The first call starts a watcher that emitsSYSTEM_ACCENT_COLOR_CHANGED. The code lives innative/accent.rs:org.freedesktop.appearance/accent-colorfrom the XDG settings portal (GNOME 47+, KDE Plasma 6), usingnative::portallike the button layout. The portal reports "no accent" as values outside 0–1.UISettings.GetColorValue(UIColorType::Accent), followingColorValuesChanged.NSColor.controlAccentColorconverted to sRGB, followingNSSystemColorsDidChangeNotification. "Multicolor" reports the system blue.WindowService(Linux, Windows and macOS) setsdata-system-accentand--system-accent-*on<html>.custom-theme.scssthen uses the accent for both the primary and the accent roles:--primary-color*,--accent-color*,--accent-bg-color,--accent-fg-colorand 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.--primary-fg-colorcarries that; on the default green it stays dark, as before.LOCKED_NATIVE_COMMANDS,PUBLIC_EVENTS), like the theme and button layout, since they only affect how the window looks.Tests
cargo fmtand clippy-D warningsfor the Linux desktop build; the accent module also passes clippy-D warningsforx86_64-pc-windows-msvcandaarch64-apple-darwin.accentPalettematches libadwaita's derived colours, picks the text colour on the fill, and rejects malformed input.WindowServiceapplies 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 buildandaudit:i18nare 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.