Skip to content

Emit accent color changes on Linux - #707

Open
049er wants to merge 6 commits into
material-foundation:mainfrom
049er:feat/linux-accent-color-changes
Open

049er wants to merge 6 commits into
material-foundation:mainfrom
049er:feat/linux-accent-color-changes

Conversation

@049er

@049er 049er commented Nov 6, 2026 •

Copy link
Copy Markdown

Description

Adds DynamicColorPlugin.onAccentColorChanged, a stream of the accent color each time the XDG Desktop Portal accent-color setting changes. DynamicColorBuilder listens to it, so apps follow the system accent color without a restart. The stream is empty on all other platforms.

This builds on #694 and the approach in #705 by @shaakunuigurumi. Compared with #705 it leaves dynamic_color_testing unchanged so flutter pub get resolves, updates DynamicColorBuilder and keeps a change that arrives during its first read, emits the GTK theme color when the setting becomes unset, and accepts the signal only from the portal and only for the org.freedesktop.appearance namespace.

The branch includes #706. Those commits drop out of the diff once #706 is merged. If this merges first, the 2.1.1 and 2.2.0 changelog sections can be folded into one.

Tests

Unit tests for the stream and the builder. flutter test passes.

Tested with Flutter 3.44.1 stable in a small app that uses the stream and the builder:

  • GNOME, Ubuntu 26.04, real portal: changes made with gsettings arrive and the builder rebuilds each time.
  • KDE Plasma 6.6 on Wayland in a VM, real portal: changes made with plasma-apply-colorscheme arrive and the builder rebuilds. The portal sends each change twice and the stream emits it once. The portal reports the previous color after a change, so that is what arrives.
  • Fake portal: an in-range value is emitted, an out-of-range or non-tuple value emits the GTK theme color, and nothing is emitted when the theme has no color either. Other keys, other namespaces and other senders are ignored. A change while nothing is listening is dropped, and listening again works.
  • No session bus: the stream emits nothing and getAccentColor still returns the GTK theme color.
  • Android 16 phone and Chrome: the stream is empty, no errors.

With the engine shut down during a pending read and a change then arriving, the app logged an invalid object or crashed in 10 of 10 runs before the channel reference was added, and in 0 of 10 after.

The Analyze Dart code check already fails on main because of deprecation warnings. This change adds none.

Not tested on other desktops, or on Windows and macOS beyond the unit tests that override the platform.

Issues

Part of #300

Checklist

Contributed by Werner Scholtz, with thanks to KDAB.

Added a range check on the portal's accent-color channels.
Bumped the version to 2.1.1.
@049er
049er marked this pull request as ready for review November 6, 2026 07:03
Read the accent color asynchronously, with a two second timeout.
Unwrapped the portal value however many variants wrap it.
@049er
049er force-pushed the feat/linux-accent-color-changes branch from b784857 to ba85487 Compare November 6, 2026 07:12
getAccentColor now returns null when the GTK theme has no accent color or the view is gone.
Updated the plugin's doc comments.
@049er
049er force-pushed the feat/linux-accent-color-changes branch from ba85487 to 93eb631 Compare November 6, 2026 10:02
049er and others added 2 commits November 10, 2026 15:05
Added DynamicColorPlugin.onAccentColorChanged, backed by the XDG portal's SettingChanged signal.
DynamicColorBuilder now updates its color schemes when the accent color changes on Linux.
The accent color example now shows changes.
Added tests for the stream and the builder.
Bumped the version to 2.2.0.

Co-authored-by: shaakunuigurumi <188075782+shaakunuigurumi@users.noreply.github.com>
Passed org.freedesktop.appearance as arg0 to the SettingChanged subscription.
@049er
049er force-pushed the feat/linux-accent-color-changes branch from 93eb631 to a5e08da Compare November 10, 2026 13:05

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant