Follow the desktop accent colour and colour scheme (XDG portal)
CI / check (pull_request) Successful in 10s
CI / native (pull_request) Successful in 1m18s

Read org.freedesktop.appearance accent-color and color-scheme from
org.freedesktop.portal.Settings over GDBus in the GTK stub and follow
SettingChanged. The accent recolours the selected tab, sliders, peak
meters and the checked Default button through an application-priority
GtkCssProvider (named colours and --accent-* variables too, for themes
that use them); the colour scheme sets the theme's dark/light variant.
Without a portal or accent the theme's own stays.

Colour conversion, WCAG contrast (readable foreground on the accent,
readable accent text on the window) and the CSS live in model/accent.mbt
with unit tests. The smoke test runs a fake portal on a private session
bus, switches the accent live from green to orange and renders the tabs
again (docs/screenshots/accent-*.png).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
SpriteandClaude Opus 5.5 committed 2026-11-23 01:28:19 +00:00
1 parent bc675459d9
commit 74d85ecdfc
16 files changed
+947 -12

No files matched your search

+2 -1
View File
@@ -47,7 +47,8 @@ jobs:
ca-certificates curl git build-essential pkg-config \ ca-certificates curl git build-essential pkg-config \
libpipewire-0.3-dev libwireplumber-0.5-dev libgtk-4-dev \ libpipewire-0.3-dev libwireplumber-0.5-dev libgtk-4-dev \
pipewire pipewire-bin wireplumber libgtk-4-bin \ pipewire pipewire-bin wireplumber libgtk-4-bin \
adwaita-icon-theme fonts-dejavu-core adwaita-icon-theme fonts-dejavu-core \
dbus-daemon python3-gi gir1.2-glib-2.0
- name: Checkout - name: Checkout
env: env:
+41 -2
View File
@@ -15,7 +15,11 @@ on top of libpipewire-0.3. It never runs `wpctl`, `pactl`, `pw-cli`,
| ![Recording tab](docs/screenshots/recording.png) | ![Input Devices tab](docs/screenshots/input-devices.png) | | ![Recording tab](docs/screenshots/recording.png) | ![Input Devices tab](docs/screenshots/input-devices.png) |
*(Rendered headlessly against a private PipeWire with null sinks; see *(Rendered headlessly against a private PipeWire with null sinks; see
[Testing](#testing).)* [Testing](#testing).)* With an orange system accent colour:
| Playback | Output Devices |
| --- | --- |
| ![Playback tab, orange accent](docs/screenshots/accent-playback.png) | ![Output Devices tab, orange accent](docs/screenshots/accent-output-devices.png) |
## Features (v1) ## Features (v1)
@@ -31,6 +35,8 @@ on top of libpipewire-0.3. It never runs `wpctl`, `pactl`, `pw-cli`,
- Volumes in percent exactly like pavucontrol/wpctl: the cubic mapping of - Volumes in percent exactly like pavucontrol/wpctl: the cubic mapping of
PipeWire's linear `channelVolumes`, up to 150%, with the dB value next to PipeWire's linear `channelVolumes`, up to 150%, with the dB value next to
it. One slider moves all channels, keeping the channel balance. it. One slider moves all channels, keeping the channel balance.
- **Follows the desktop's accent colour and dark/light style**, live (see
[Appearance](#appearance)).
- Live updates: devices and streams appearing, disappearing or changing - Live updates: devices and streams appearing, disappearing or changing
elsewhere (another mixer, keyboard volume keys, a new Bluetooth headset) elsewhere (another mixer, keyboard volume keys, a new Bluetooth headset)
show up immediately. show up immediately.
@@ -88,6 +94,34 @@ flowchart LR
time after the user moves a slider, remote updates to that slider are time after the user moves a slider, remote updates to that slider are
ignored so it doesn't jump while being dragged. ignored so it doesn't jump while being dragged.
## Appearance
moonmix reads the desktop's **accent colour** and **colour scheme** from the
XDG Desktop Portal (`org.freedesktop.portal.Settings`, namespace
`org.freedesktop.appearance`: `accent-color` and `color-scheme`), which GNOME
47+, KDE Plasma 6 and others implement, over GDBus in `gtk/gtk_stub.c`, and
follows `SettingChanged`, so changing them in the system settings applies at
once. The selected tab, the volume sliders, the peak meters and the checked
*Default* button take the accent colour; a dark/light preference switches the
theme's variant (`gtk-application-prefer-dark-theme`, and
`gtk-interface-color-scheme` on GTK 4.20+).
The colours come from `model/accent.mbt` (unit-tested): text and icons on
accent backgrounds are white while that reaches a 3:1 WCAG contrast, else
whichever of white and black contrasts more (black on orange or yellow); the
accent used as a text colour is darkened or lightened until it reaches 4.5:1
on the window background. They are applied by a `GtkCssProvider` at
application priority that sets the accent named colours (`accent_bg_color`,
`accent_fg_color`, `accent_color`, `theme_selected_bg_color`, and the
`--accent-*` variables) for themes that use them, plus explicit rules, since
GTK's built-in Default theme hardcodes its blue.
Without a portal, or when no accent is set, the theme's own accent stays.
moonmix uses the portal directly rather than libadwaita (whose
`AdwStyleManager` does the same on 1.6+) to keep GTK's standard look and
avoid a dependency and a move to `AdwApplication`.
## Building ## Building
### Dependencies ### Dependencies
@@ -176,6 +210,7 @@ $P meter <id> # peak over ~1.5 s; exit 6 if silent
moon test --target wasm-gc # pure model tests, no libraries needed moon test --target wasm-gc # pure model tests, no libraries needed
moon check --target native # type-check everything moon check --target native # type-check everything
tools/smoke-test.sh /tmp/shot # needs pipewire, wireplumber, pw-cat, gtk4-broadwayd tools/smoke-test.sh /tmp/shot # needs pipewire, wireplumber, pw-cat, gtk4-broadwayd
# (+ python3-gi, dbus-daemon for the accent shots)
``` ```
`tools/smoke-test.sh` starts a private PipeWire and WirePlumber in a temp `tools/smoke-test.sh` starts a private PipeWire and WirePlumber in a temp
@@ -184,7 +219,11 @@ microphone, one playback stream of noise and one capture stream created with `pw
by the test harness. The script runs every probe action and checks its effect, checks that peak by the test harness. The script runs every probe action and checks its effect, checks that peak
meters on the stream and its sink see the signal, meters on the stream and its sink see the signal,
then starts the GUI under GTK's broadway backend. With `MOONMIX_SCREENSHOT` then starts the GUI under GTK's broadway backend. With `MOONMIX_SCREENSHOT`
set, the GUI renders each tab offscreen to a PNG and exits. set, the GUI renders each tab offscreen to a PNG and exits. If `python3`
with PyGObject and `dbus-daemon` are available, it then starts a private
session bus with a fake portal (`tools/fake-portal.py`) that reports a green
accent, switches it to orange while moonmix runs, and renders the tabs again
(`<prefix>-accent-<n>.png`) once the change has been applied.
CI (`.gitea/workflows/ci.yaml`) runs the pure checks on the default runner. CI (`.gitea/workflows/ci.yaml`) runs the pure checks on the default runner.
It runs the native build and the smoke test in a `debian:trixie` container, It runs the native build and the smoke test in a `debian:trixie` container,
+65 -5
View File
@@ -134,6 +134,8 @@ fn new_row_view(app : App, tab : @model.Tab, row : @model.Row) -> RowView {
) )
tags.push(tag) tags.push(tag)
b.set_tooltip("Set as default (fallback) device") b.set_tooltip("Set as default (fallback) device")
// Shown in the accent colour when checked (see @model.accent_css).
b.add_css_class("mm-default")
header.append(b) header.append(b)
Some(b) Some(b)
} }
@@ -470,10 +472,52 @@ fn build_ui() -> App {
app app
} }
///|
/// Follow the desktop's accent colour and dark/light preference (XDG Desktop
/// Portal). Without a portal, or with no accent set, the theme's own accent
/// stays.
///|
/// The accent applied last ("#rrggbb", or "" for the theme's own).
let applied_accent : Ref[String] = { val: "", }
///|
fn follow_appearance(log~ : Bool = false) -> Unit {
let _ = @gtk.watch_appearance(fn(a) {
let scheme = @model.ColorScheme::from_portal(a.color_scheme)
@gtk.set_color_scheme(a.color_scheme)
let dark = match scheme {
Dark => true
Light => false
NoPreference => @gtk.prefers_dark()
}
let (r, g, b) = a.accent
let accent = @model.Rgb::from_portal(r, g, b)
match accent {
Some(c) => @gtk.set_accent_css(@model.accent_css(c, dark))
None => @gtk.set_accent_css("")
}
applied_accent.val = match accent {
Some(c) => c.to_hex()
None => ""
}
if log {
// The smoke test checks these lines to see live updates arrive.
let name = match accent {
Some(c) => c.to_hex()
None => "theme default"
}
println("moonmix: accent \{name}, \{if dark { "dark" } else { "light" }}")
}
})
}
///| ///|
/// Test hook: MOONMIX_SCREENSHOT=/path/prefix renders every tab to /// Test hook: MOONMIX_SCREENSHOT=/path/prefix renders every tab to
/// <prefix>-<n>.png once connected, then exits. Used for headless CI/smoke /// <prefix>-<n>.png once connected, then exits. Used for headless CI/smoke
/// runs (GDK_BACKEND=broadway or x11 under Xvfb). /// runs (GDK_BACKEND=broadway or x11 under Xvfb). With
/// MOONMIX_SCREENSHOT_ACCENT=#rrggbb it first waits (up to 20 s) until the
/// portal has delivered that accent colour.
fn screenshot_mode(app : App, prefix : String) -> Unit { fn screenshot_mode(app : App, prefix : String) -> Unit {
let tab_count = app.tabs.length() let tab_count = app.tabs.length()
// Offscreen rendering occasionally yields an empty frame right after a tab // Offscreen rendering occasionally yields an empty frame right after a tab
@@ -504,7 +548,19 @@ fn screenshot_mode(app : App, prefix : String) -> Unit {
}) })
} }
@gtk.timeout(1500, fn() { shoot(0, 0) }) let want = env_var("MOONMIX_SCREENSHOT_ACCENT").unwrap_or("")
fn start(waited : Int32) -> Unit {
if want == "" || applied_accent.val == want || waited >= 200 {
if waited >= 200 {
println("moonmix: accent \{want} never arrived")
}
shoot(0, 0)
} else {
@gtk.timeout(100, fn() { start(waited + 1) })
}
}
@gtk.timeout(1500, fn() { start(0) })
} }
///| ///|
@@ -518,6 +574,11 @@ fn main {
println("moonmix: cannot open a display (is WAYLAND_DISPLAY/DISPLAY set?)") println("moonmix: cannot open a display (is WAYLAND_DISPLAY/DISPLAY set?)")
c_exit(1) c_exit(1)
} }
let screenshot = match env_var("MOONMIX_SCREENSHOT") {
Some(prefix) if prefix != "" => Some(prefix)
_ => None
}
follow_appearance(log=screenshot is Some(_))
let app = build_ui() let app = build_ui()
@wp.on_event(fn(ev) { app.on_wp_event(ev) }) @wp.on_event(fn(ev) { app.on_wp_event(ev) })
if !@wp.start() { if !@wp.start() {
@@ -525,9 +586,8 @@ fn main {
} }
app.window.present() app.window.present()
app.start_meter_timer() app.start_meter_timer()
match env_var("MOONMIX_SCREENSHOT") { if screenshot is Some(prefix) {
Some(prefix) if prefix != "" => screenshot_mode(app, prefix) screenshot_mode(app, prefix)
_ => ()
} }
@gtk.run() @gtk.run()
} }
Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

+62
View File
@@ -286,6 +286,68 @@ pub fn load_css(css : String) -> Unit {
ffi_load_css(cstr(css)) ffi_load_css(cstr(css))
} }
///|
extern "C" fn ffi_portal_watch(tag : Int32) -> Int32 = "mm_gtk_portal_watch"
///|
extern "C" fn ffi_portal_accent(i : Int32) -> Double = "mm_gtk_portal_accent"
///|
extern "C" fn ffi_portal_color_scheme() -> Int32 = "mm_gtk_portal_color_scheme"
///|
#borrow(css)
extern "C" fn ffi_set_accent_css(css : Bytes) = "mm_gtk_set_accent_css"
///|
extern "C" fn ffi_prefers_dark() -> Int32 = "mm_gtk_prefers_dark"
///|
extern "C" fn ffi_set_color_scheme(scheme : Int32) = "mm_gtk_set_color_scheme"
///|
/// The desktop's appearance settings, from the XDG Desktop Portal.
pub(all) struct Appearance {
/// accent-color as reported (each channel -1 when unset).
accent : (Double, Double, Double)
/// color-scheme: 0 no preference, 1 dark, 2 light.
color_scheme : Int32
}
///|
/// Follow org.freedesktop.appearance (accent-color, color-scheme) through
/// the portal's Settings interface: `f` runs once with the current values
/// and again on every change. Never runs without a portal. False without a
/// session bus.
pub fn watch_appearance(f : (Appearance) -> Unit) -> Bool {
let tag = register(fn(_) {
f({
accent: (ffi_portal_accent(0), ffi_portal_accent(1), ffi_portal_accent(2)),
color_scheme: ffi_portal_color_scheme(),
})
})
ffi_portal_watch(tag) != 0
}
///|
/// Replace the accent stylesheet (APPLICATION priority); "" removes it.
pub fn set_accent_css(css : String) -> Unit {
ffi_set_accent_css(cstr(css))
}
///|
/// Apply a color-scheme preference (0 none: back to the configured theme
/// variant, 1 dark, 2 light).
pub fn set_color_scheme(scheme : Int32) -> Unit {
ffi_set_color_scheme(scheme)
}
///|
/// Whether the theme is in its dark variant.
pub fn prefers_dark() -> Bool {
ffi_prefers_dark() != 0
}
///| ///|
pub fn window( pub fn window(
title : String, title : String,
+190
View File
@@ -165,6 +165,196 @@ MOONBIT_FFI_EXPORT void mm_gtk_load_css(moonbit_bytes_t css) {
g_object_unref(p); g_object_unref(p);
} }
/* ---- desktop appearance (XDG Desktop Portal Settings) -------------------
*
* Reads org.freedesktop.appearance accent-color ((ddd), sRGB 0..1; outside
* that range means unset) and color-scheme (u: 0 none, 1 dark, 2 light) from
* org.freedesktop.portal.Settings on the session bus, and follows
* SettingChanged. Every change is reported to MoonBit as emit(tag, 0); it
* then reads the values with mm_gtk_portal_accent / _color_scheme. Without
* a session bus or portal nothing is ever reported: the theme stays as is. */
#define PORTAL_NAME "org.freedesktop.portal.Desktop"
#define PORTAL_PATH "/org/freedesktop/portal/desktop"
#define PORTAL_IFACE "org.freedesktop.portal.Settings"
#define APPEARANCE_NS "org.freedesktop.appearance"
static GDBusConnection *g_portal_bus;
static int32_t g_portal_tag;
static double g_accent[3] = {-1, -1, -1};
static int32_t g_color_scheme;
static GtkCssProvider *g_accent_provider;
/* Store one appearance setting; 1 if it is one we track. */
static int portal_store(const char *key, GVariant *value) {
GVariant *v = g_variant_ref(value);
while (g_variant_is_of_type(v, G_VARIANT_TYPE_VARIANT)) {
GVariant *inner = g_variant_get_variant(v);
g_variant_unref(v);
v = inner;
}
int known = 1;
if (strcmp(key, "accent-color") == 0 &&
g_variant_is_of_type(v, G_VARIANT_TYPE("(ddd)")))
g_variant_get(v, "(ddd)", &g_accent[0], &g_accent[1], &g_accent[2]);
else if (strcmp(key, "color-scheme") == 0 &&
g_variant_is_of_type(v, G_VARIANT_TYPE_UINT32))
g_color_scheme = (int32_t)g_variant_get_uint32(v);
else
known = 0;
g_variant_unref(v);
return known;
}
static void on_portal_setting_changed(GDBusConnection *c, const char *sender,
const char *path, const char *iface,
const char *signal, GVariant *params,
gpointer d) {
(void)c; (void)sender; (void)path; (void)iface; (void)signal; (void)d;
const char *ns, *key;
GVariant *value;
if (!g_variant_is_of_type(params, G_VARIANT_TYPE("(ssv)")))
return;
g_variant_get(params, "(&s&sv)", &ns, &key, &value);
int known = strcmp(ns, APPEARANCE_NS) == 0 && portal_store(key, value);
g_variant_unref(value);
if (known)
emit(g_portal_tag, 0);
}
static void on_portal_read_all(GObject *src, GAsyncResult *res, gpointer d) {
(void)d;
GError *err = NULL;
GVariant *ret = g_dbus_connection_call_finish(G_DBUS_CONNECTION(src), res, &err);
if (!ret) {
/* No portal (or no Settings interface): keep the theme's accent. */
g_debug("moonmix: no desktop portal settings: %s", err->message);
g_error_free(err);
return;
}
GVariantIter *namespaces;
const char *ns;
GVariant *entries;
g_variant_get(ret, "(a{sa{sv}})", &namespaces);
while (g_variant_iter_next(namespaces, "{&s@a{sv}}", &ns, &entries)) {
if (strcmp(ns, APPEARANCE_NS) == 0) {
GVariantIter it;
const char *key;
GVariant *value;
g_variant_iter_init(&it, entries);
while (g_variant_iter_next(&it, "{&sv}", &key, &value)) {
portal_store(key, value);
g_variant_unref(value);
}
}
g_variant_unref(entries);
}
g_variant_iter_free(namespaces);
g_variant_unref(ret);
emit(g_portal_tag, 0);
}
/* Start following the portal's appearance settings. 0 without a session
* bus. */
MOONBIT_FFI_EXPORT int32_t mm_gtk_portal_watch(int32_t tag) {
g_portal_tag = tag;
if (g_portal_bus)
return 1;
GError *err = NULL;
g_portal_bus = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &err);
if (!g_portal_bus) {
g_debug("moonmix: no session bus: %s", err->message);
g_error_free(err);
return 0;
}
/* Subscribe first so no change between the read and the subscription is
* lost. */
g_dbus_connection_signal_subscribe(
g_portal_bus, PORTAL_NAME, PORTAL_IFACE, "SettingChanged", PORTAL_PATH,
APPEARANCE_NS, G_DBUS_SIGNAL_FLAGS_NONE, on_portal_setting_changed, NULL,
NULL);
const char *namespaces[] = {APPEARANCE_NS, NULL};
g_dbus_connection_call(
g_portal_bus, PORTAL_NAME, PORTAL_PATH, PORTAL_IFACE, "ReadAll",
g_variant_new("(^as)", namespaces), G_VARIANT_TYPE("(a{sa{sv}})"),
G_DBUS_CALL_FLAGS_NONE, 5000, NULL, on_portal_read_all, NULL);
return 1;
}
/* Channel i (0 r, 1 g, 2 b) of the portal accent colour; -1 when unset. */
MOONBIT_FFI_EXPORT double mm_gtk_portal_accent(int32_t i) {
return i >= 0 && i < 3 ? g_accent[i] : -1;
}
MOONBIT_FFI_EXPORT int32_t mm_gtk_portal_color_scheme(void) {
return g_color_scheme;
}
/* Replace the accent stylesheet ("" removes it, restoring the theme's). */
MOONBIT_FFI_EXPORT void mm_gtk_set_accent_css(moonbit_bytes_t css) {
GdkDisplay *d = gdk_display_get_default();
if (!d)
return;
if (!*s(css)) {
if (g_accent_provider) {
gtk_style_context_remove_provider_for_display(
d, GTK_STYLE_PROVIDER(g_accent_provider));
g_clear_object(&g_accent_provider);
}
return;
}
if (!g_accent_provider) {
g_accent_provider = gtk_css_provider_new();
gtk_style_context_add_provider_for_display(
d, GTK_STYLE_PROVIDER(g_accent_provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
}
gtk_css_provider_load_from_string(g_accent_provider, s(css));
}
/* 1 if the theme is in its dark variant now. */
MOONBIT_FFI_EXPORT int32_t mm_gtk_prefers_dark(void) {
GtkSettings *st = gtk_settings_get_default();
gboolean dark = FALSE;
if (st)
g_object_get(st, "gtk-application-prefer-dark-theme", &dark, NULL);
return dark;
}
/* Apply the color-scheme preference: 1 dark, 2 light, else whatever was set
* before moonmix first touched it (settings.ini, GTK_THEME...). */
MOONBIT_FFI_EXPORT void mm_gtk_set_color_scheme(int32_t scheme) {
static int saved = -1;
#if GTK_CHECK_VERSION(4, 20, 0)
static int saved_scheme = -1;
#endif
GtkSettings *st = gtk_settings_get_default();
if (!st)
return;
if (saved < 0) {
gboolean dark = FALSE;
g_object_get(st, "gtk-application-prefer-dark-theme", &dark, NULL);
saved = dark;
}
gboolean dark = scheme == 1 ? TRUE : scheme == 2 ? FALSE : saved;
g_object_set(st, "gtk-application-prefer-dark-theme", dark, NULL);
#if GTK_CHECK_VERSION(4, 20, 0)
/* Also drives CSS prefers-color-scheme on GTK 4.20+. */
if (g_object_class_find_property(G_OBJECT_GET_CLASS(st),
"gtk-interface-color-scheme")) {
int cur;
g_object_get(st, "gtk-interface-color-scheme", &cur, NULL);
if (saved_scheme < 0)
saved_scheme = cur;
int want = scheme == 1 ? GTK_INTERFACE_COLOR_SCHEME_DARK
: scheme == 2 ? GTK_INTERFACE_COLOR_SCHEME_LIGHT
: saved_scheme;
if (want != cur)
g_object_set(st, "gtk-interface-color-scheme", want, NULL);
}
#endif
}
/* ---- window ------------------------------------------------------------- */ /* ---- window ------------------------------------------------------------- */
static gboolean on_close(GtkWindow *w, gpointer d) { static gboolean on_close(GtkWindow *w, gpointer d) {
+13
View File
@@ -24,6 +24,8 @@ pub fn notebook(on_switch? : (Int32) -> Unit) -> Widget
pub fn now_us() -> Int64 pub fn now_us() -> Int64
pub fn prefers_dark() -> Bool
pub fn quit() -> Unit pub fn quit() -> Unit
pub fn resolve_icon(Array[String]) -> String pub fn resolve_icon(Array[String]) -> String
@@ -36,6 +38,10 @@ pub fn scrolled(Widget) -> Widget
pub fn separator() -> Widget pub fn separator() -> Widget
pub fn set_accent_css(String) -> Unit
pub fn set_color_scheme(Int32) -> Unit
pub fn timeout(Int32, () -> Unit) -> Unit pub fn timeout(Int32, () -> Unit) -> Unit
pub fn toggle(String, String, (Bool) -> Unit) -> (Widget, Int32) pub fn toggle(String, String, (Bool) -> Unit) -> (Widget, Int32)
@@ -46,11 +52,18 @@ pub fn updating(() -> Unit) -> Unit
pub fn vbox(Int32) -> Widget pub fn vbox(Int32) -> Widget
pub fn watch_appearance((Appearance) -> Unit) -> Bool
pub fn window(String, Int32, Int32, on_close? : () -> Unit) -> Widget pub fn window(String, Int32, Int32, on_close? : () -> Unit) -> Widget
// Errors // Errors
// Types and methods // Types and methods
pub(all) struct Appearance {
accent : (Double, Double, Double)
color_scheme : Int32
}
#external #external
pub type Widget pub type Widget
pub fn Widget::add_css_class(Self, String) -> Unit pub fn Widget::add_css_class(Self, String) -> Unit
+257
View File
@@ -0,0 +1,257 @@
// System accent colour: conversion of the XDG Desktop Portal value
// (org.freedesktop.appearance accent-color, an (ddd) sRGB tuple in 0..1),
// WCAG contrast checks, and the CSS that recolours moonmix with it.
///|
/// An sRGB colour, each channel 0..1.
#derive(Eq, Debug)
pub(all) struct Rgb {
r : Double
g : Double
b : Double
}
///|
pub let white : Rgb = { r: 1.0, g: 1.0, b: 1.0, }
///|
pub let black : Rgb = { r: 0.0, g: 0.0, b: 0.0, }
///|
/// The portal's accent colour, or None when it is unset. The spec says a
/// value outside 0..1 means "no accent colour" (GNOME sends that before the
/// user picks one); NaN counts as unset too.
pub fn Rgb::from_portal(r : Double, g : Double, b : Double) -> Rgb? {
fn ok(x : Double) -> Bool {
x >= 0.0 && x <= 1.0 // false for NaN
}
if ok(r) && ok(g) && ok(b) {
Some({ r, g, b, })
} else {
None
}
}
///|
fn byte(x : Double) -> Int32 {
let v = (x * 255.0 + 0.5).to_int()
if v < 0 {
0
} else if v > 255 {
255
} else {
v
}
}
///|
/// Parse "#rrggbb" or "#rgb" (case-insensitive).
pub fn Rgb::parse_hex(s : String) -> Rgb? {
fn nib(c : Char) -> Int32? {
match c {
'0'..<='9' => Some(c.to_int() - '0'.to_int())
'a'..<='f' => Some(c.to_int() - 'a'.to_int() + 10)
'A'..<='F' => Some(c.to_int() - 'A'.to_int() + 10)
_ => None
}
}
let cs = s.to_array()
if cs.length() == 0 || cs[0] != '#' {
return None
}
let ds = []
for c in cs[1:] {
match nib(c) {
Some(d) => ds.push(d)
None => return None
}
}
let (r, g, b) = match ds.length() {
6 => (ds[0] * 16 + ds[1], ds[2] * 16 + ds[3], ds[4] * 16 + ds[5])
3 => (ds[0] * 17, ds[1] * 17, ds[2] * 17)
_ => return None
}
Some({
r: r.to_double() / 255.0,
g: g.to_double() / 255.0,
b: b.to_double() / 255.0,
})
}
///|
/// "#rrggbb", for CSS.
pub fn Rgb::to_hex(self : Rgb) -> String {
let digits = "0123456789abcdef".to_array()
let out = StringBuilder()
out.write_char('#')
for x in [self.r, self.g, self.b] {
let v = byte(x)
out.write_char(digits[v / 16])
out.write_char(digits[v % 16])
}
out.to_string()
}
///|
/// Linear interpolation: t = 0 is self, t = 1 is other.
pub fn Rgb::mix(self : Rgb, other : Rgb, t : Double) -> Rgb {
{
r: self.r + (other.r - self.r) * t,
g: self.g + (other.g - self.g) * t,
b: self.b + (other.b - self.b) * t,
}
}
///|
/// WCAG 2 relative luminance (of the colour as it will be shown, i.e.
/// rounded to 8 bits).
pub fn Rgb::luminance(self : Rgb) -> Double {
fn lin(x : Double) -> Double {
let c = byte(x).to_double() / 255.0
if c <= 0.04045 {
c / 12.92
} else {
@math.pow((c + 0.055) / 1.055, 2.4)
}
}
0.2126 * lin(self.r) + 0.7152 * lin(self.g) + 0.0722 * lin(self.b)
}
///|
/// WCAG 2 contrast ratio, 1..21.
pub fn contrast_ratio(a : Rgb, b : Rgb) -> Double {
let la = a.luminance()
let lb = b.luminance()
let (hi, lo) = if la > lb { (la, lb) } else { (lb, la) }
(hi + 0.05) / (lo + 0.05)
}
///|
/// WCAG AA contrast for normal text.
pub const MIN_TEXT_CONTRAST : Double = 4.5
///|
/// WCAG AA contrast for bold/large text and UI components (the checked
/// "default" button's icon, selected rows' text).
pub const MIN_UI_CONTRAST : Double = 3.0
///|
/// Foreground for text and icons on an accent background: white, as GTK and
/// libadwaita use, while it reaches MIN_UI_CONTRAST; otherwise whichever of
/// white and black contrasts more (black on yellow, light green, orange…).
pub fn readable_fg(bg : Rgb) -> Rgb {
let on_white = contrast_ratio(bg, white)
if on_white >= MIN_UI_CONTRAST || on_white >= contrast_ratio(bg, black) {
white
} else {
black
}
}
///|
/// Window background of GTK's Default theme (theme_bg_color).
pub fn window_bg(dark : Bool) -> Rgb {
if dark {
{ r: 53.0 / 255.0, g: 53.0 / 255.0, b: 53.0 / 255.0, } // #353535
} else {
{ r: 246.0 / 255.0, g: 245.0 / 255.0, b: 244.0 / 255.0, } // #f6f5f4
}
}
///|
/// The accent as a text/link colour on the window background: the accent
/// itself if it is readable there, else darkened (light scheme) or lightened
/// (dark scheme) just enough to be.
pub fn accent_text_color(accent : Rgb, dark : Bool) -> Rgb {
let bg = window_bg(dark)
let toward = if dark { white } else { black }
for i in 0..<=20 {
let c = accent.mix(toward, i.to_double() * 0.05)
if contrast_ratio(c, bg) >= MIN_TEXT_CONTRAST {
return c
}
}
toward
}
///|
/// The colours derived from one accent.
#derive(Eq, Debug)
pub(all) struct AccentColors {
/// Backgrounds: selected tab underline, slider fill, level bar, the
/// checked "default" button.
bg : Rgb
/// Text and icons on `bg`.
fg : Rgb
/// Accent used as a text colour on the window background.
text : Rgb
/// Outline of filled buttons and checks: a slightly darker accent, as the
/// theme does.
border : Rgb
}
///|
pub fn AccentColors::new(accent : Rgb, dark : Bool) -> AccentColors {
{
bg: accent,
fg: readable_fg(accent),
text: accent_text_color(accent, dark),
border: accent.mix(black, 0.15),
}
}
///|
/// CSS (for a provider at APPLICATION priority) that makes the theme use
/// the accent. Overrides the accent named colours and CSS variables (for
/// Adwaita-style themes and GTK 3-style themes that use
/// theme_selected_bg_color), plus explicit rules for the widgets moonmix
/// uses, because GTK's built-in Default theme hardcodes its blue.
pub fn accent_css(accent : Rgb, dark : Bool) -> String {
let c = AccentColors::new(accent, dark)
let bg = c.bg.to_hex()
let fg = c.fg.to_hex()
let text = c.text.to_hex()
let border = c.border.to_hex()
let lines = [
"@define-color accent_bg_color \{bg};",
"@define-color accent_fg_color \{fg};",
"@define-color accent_color \{text};",
"@define-color theme_selected_bg_color \{bg};",
"@define-color theme_selected_fg_color \{fg};",
":root { --accent-bg-color: \{bg}; --accent-fg-color: \{fg}; --accent-color: \{text}; }",
"scale > trough > highlight { background-color: \{bg}; border-color: \{bg}; }",
"levelbar > trough > block.high, levelbar > trough > block:not(.empty):not(.low):not(.full) { background-color: \{bg}; border-color: \{bg}; }",
"notebook > header.top > tabs > tab:checked { box-shadow: inset 0 -4px \{bg}; }",
"notebook > header.bottom > tabs > tab:checked { box-shadow: inset 0 4px \{bg}; }",
"notebook > header.left > tabs > tab:checked { box-shadow: inset -4px 0 \{bg}; }",
"notebook > header.right > tabs > tab:checked { box-shadow: inset 4px 0 \{bg}; }",
"button.mm-default:checked { background-image: none; background-color: \{bg}; border-color: \{border}; color: \{fg}; }",
"check:checked, radio:checked, switch:checked { background-image: none; background-color: \{bg}; border-color: \{border}; color: \{fg}; }",
"row:selected, .view:selected { background-color: \{bg}; color: \{fg}; }",
"link, button.link { color: \{text}; }",
":focus-visible { outline-color: alpha(\{bg}, 0.5); }",
]
lines.join("\n") + "\n"
}
///|
/// The portal's color-scheme preference.
#derive(Eq, Debug)
pub(all) enum ColorScheme {
NoPreference
Dark
Light
}
///|
/// org.freedesktop.appearance color-scheme: 1 dark, 2 light, else none.
pub fn ColorScheme::from_portal(v : Int32) -> ColorScheme {
match v {
1 => Dark
2 => Light
_ => NoPreference
}
}
+120
View File
@@ -0,0 +1,120 @@
///|
fn hex(s : String) -> @model.Rgb {
@model.Rgb::parse_hex(s).unwrap()
}
///|
test "from_portal accepts 0..1 and rejects unset values" {
assert_eq(
@model.Rgb::from_portal(1.0, 0.5, 0.0),
Some({ r: 1.0, g: 0.5, b: 0.0, }),
)
assert_eq(@model.Rgb::from_portal(0.0, 0.0, 0.0), Some(@model.black))
// GNOME reports (-1, -1, -1) before an accent is chosen.
assert_eq(@model.Rgb::from_portal(-1.0, -1.0, -1.0), None)
assert_eq(@model.Rgb::from_portal(0.2, 1.5, 0.2), None)
assert_eq(@model.Rgb::from_portal(0.0 / 0.0, 0.2, 0.2), None)
}
///|
test "hex round trip" {
assert_eq(hex("#3584e4").to_hex(), "#3584e4")
assert_eq(hex("#ED5B00").to_hex(), "#ed5b00")
assert_eq(hex("#fff"), @model.white)
assert_eq(hex("#000000"), @model.black)
assert_eq(@model.Rgb::parse_hex("3584e4"), None)
assert_eq(@model.Rgb::parse_hex("#3584e"), None)
assert_eq(@model.Rgb::parse_hex("#zzzzzz"), None)
// Portal doubles are rounded to the nearest byte.
assert_eq(
@model.Rgb::from_portal(1.0, 0.471, 0.0).unwrap().to_hex(),
"#ff7800",
)
}
///|
test "contrast ratio" {
assert_eq(@model.contrast_ratio(@model.white, @model.black), 21.0)
assert_eq(@model.contrast_ratio(@model.black, @model.black), 1.0)
// GTK's blue against white (well known: ~3.76).
let r = @model.contrast_ratio(hex("#3584e4"), @model.white)
assert_true(r > 3.7 && r < 3.8)
// Symmetric.
assert_eq(@model.contrast_ratio(@model.white, hex("#3584e4")), r)
}
///|
test "readable foreground on accent backgrounds" {
// Dark accents keep white text.
assert_eq(@model.readable_fg(hex("#1c71d8")), @model.white)
assert_eq(@model.readable_fg(hex("#9141ac")), @model.white)
assert_eq(@model.readable_fg(hex("#c01c28")), @model.white)
// GTK's blue: below 4.5 with white (black would contrast more), but
// above 3, so it keeps white like GTK does.
assert_eq(@model.readable_fg(hex("#3584e4")), @model.white)
// Bright accents get black text.
assert_eq(@model.readable_fg(hex("#ff7800")), @model.black)
assert_eq(@model.readable_fg(hex("#f6d32d")), @model.black)
assert_eq(@model.readable_fg(hex("#33d17a")), @model.black)
// Whatever is chosen beats the alternative or meets AA.
for c in ["#3584e4", "#ff7800", "#2190a4", "#c88800", "#6f8396", "#ffffff"] {
let bg = hex(c)
let fg = @model.readable_fg(bg)
let other = if fg == @model.white { @model.black } else { @model.white }
assert_true(
@model.contrast_ratio(bg, fg) >= @model.MIN_UI_CONTRAST ||
@model.contrast_ratio(bg, fg) >= @model.contrast_ratio(bg, other),
)
}
}
///|
test "accent text colour is readable on the window background" {
for
c in [
"#3584e4", "#ff7800", "#f6d32d", "#33d17a", "#1c71d8", "#000000", "#ffffff",
] {
for dark in [false, true] {
let t = @model.accent_text_color(hex(c), dark)
assert_true(
@model.contrast_ratio(t, @model.window_bg(dark)) >=
@model.MIN_TEXT_CONTRAST,
)
}
}
// Already readable: unchanged.
assert_eq(@model.accent_text_color(hex("#1a5fb4"), false), hex("#1a5fb4"))
// Yellow on a light window is darkened, on a dark one kept.
assert_true(
@model.accent_text_color(hex("#f6d32d"), false).luminance() <
hex("#f6d32d").luminance(),
)
assert_eq(@model.accent_text_color(hex("#f6d32d"), true), hex("#f6d32d"))
}
///|
test "accent css overrides named colours and widget fills" {
let css = @model.accent_css(hex("#ff7800"), false)
assert_true(css.contains("@define-color accent_bg_color #ff7800;"))
assert_true(css.contains("@define-color accent_fg_color #000000;"))
assert_true(css.contains("@define-color theme_selected_bg_color #ff7800;"))
assert_true(css.contains("--accent-bg-color: #ff7800;"))
assert_true(
css.contains("scale > trough > highlight { background-color: #ff7800;"),
)
assert_true(css.contains("levelbar > trough > block.high"))
assert_true(css.contains("tab:checked { box-shadow: inset 0 -4px #ff7800; }"))
assert_true(css.contains("button.mm-default:checked"))
// The text colour is the darkened accent, not the raw one.
let text = @model.accent_text_color(hex("#ff7800"), false).to_hex()
assert_true(text != "#ff7800")
assert_true(css.contains("@define-color accent_color \{text};"))
}
///|
test "color scheme from portal" {
assert_eq(@model.ColorScheme::from_portal(0), @model.NoPreference)
assert_eq(@model.ColorScheme::from_portal(1), @model.Dark)
assert_eq(@model.ColorScheme::from_portal(2), @model.Light)
assert_eq(@model.ColorScheme::from_portal(7), @model.NoPreference)
}
+47
View File
@@ -14,12 +14,24 @@ pub const MAX_PERCENT : Double = 150.0
pub const METER_DECAY : Double = 0.04 pub const METER_DECAY : Double = 0.04
pub const MIN_TEXT_CONTRAST : Double = 4.5
pub const MIN_UI_CONTRAST : Double = 3.0
pub const NORM_PERCENT : Double = 100.0 pub const NORM_PERCENT : Double = 100.0
pub fn accent_css(Rgb, Bool) -> String
pub fn accent_text_color(Rgb, Bool) -> Rgb
pub let black : Rgb
pub fn clamp_percent(Double) -> Double pub fn clamp_percent(Double) -> Double
pub fn compare_text(String, String) -> Int32 pub fn compare_text(String, String) -> Int32
pub fn contrast_ratio(Rgb, Rgb) -> Double
pub fn default_button_icons() -> Array[String] pub fn default_button_icons() -> Array[String]
pub fn device_bus(Node) -> String pub fn device_bus(Node) -> String
@@ -54,6 +66,8 @@ pub fn meter_step(Double, Double) -> Double
pub fn percent_to_linear(Double) -> Double pub fn percent_to_linear(Double) -> Double
pub fn readable_fg(Rgb) -> Rgb
pub fn rows(State, Tab) -> Array[Row] pub fn rows(State, Tab) -> Array[Row]
pub fn scale_linked(Array[Double], Double) -> Array[Double] pub fn scale_linked(Array[Double], Double) -> Array[Double]
@@ -66,9 +80,30 @@ pub fn symbolic(String) -> String
pub fn volume_icon(Double, Bool) -> String pub fn volume_icon(Double, Bool) -> String
pub let white : Rgb
pub fn window_bg(Bool) -> Rgb
// Errors // Errors
// Types and methods // Types and methods
#derive(Eq, @debug.Debug)
pub(all) struct AccentColors {
bg : Rgb
fg : Rgb
text : Rgb
border : Rgb
}
pub fn AccentColors::new(Rgb, Bool) -> Self
#derive(Eq, @debug.Debug)
pub(all) enum ColorScheme {
NoPreference
Dark
Light
}
pub fn ColorScheme::from_portal(Int32) -> Self
#derive(Eq, @debug.Debug) #derive(Eq, @debug.Debug)
pub(all) struct DeviceChoice { pub(all) struct DeviceChoice {
id : Int32 id : Int32
@@ -127,6 +162,18 @@ pub(all) enum NodeKind {
} }
pub fn NodeKind::from_media_class(String) -> Self pub fn NodeKind::from_media_class(String) -> Self
#derive(Eq, @debug.Debug)
pub(all) struct Rgb {
r : Double
g : Double
b : Double
}
pub fn Rgb::from_portal(Double, Double, Double) -> Self?
pub fn Rgb::luminance(Self) -> Double
pub fn Rgb::mix(Self, Self, Double) -> Self
pub fn Rgb::parse_hex(String) -> Self?
pub fn Rgb::to_hex(Self) -> String
#derive(Eq, @debug.Debug) #derive(Eq, @debug.Debug)
pub(all) struct Row { pub(all) struct Row {
id : Int32 id : Int32
+114
View File
@@ -0,0 +1,114 @@
#!/usr/bin/env python3
"""Fake org.freedesktop.portal.Settings for the smoke test.
Owns org.freedesktop.portal.Desktop on the session bus and serves the
org.freedesktop.appearance namespace with a fixed accent colour and colour
scheme, like GNOME 47+ / KDE Plasma 6 do.
fake-portal.py R G B [COLOR_SCHEME] (channels 0..1; scheme 0/1/2)
Writing a line "R G B [SCHEME]" to stdin changes the values and emits
SettingChanged, to exercise live updates.
"""
import sys
import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning)
from gi.repository import Gio, GLib
XML = """
<node>
<interface name="org.freedesktop.portal.Settings">
<method name="ReadAll">
<arg type="as" name="namespaces" direction="in"/>
<arg type="a{sa{sv}}" name="value" direction="out"/>
</method>
<method name="Read">
<arg type="s" name="namespace" direction="in"/>
<arg type="s" name="key" direction="in"/>
<arg type="v" name="value" direction="out"/>
</method>
<method name="ReadOne">
<arg type="s" name="namespace" direction="in"/>
<arg type="s" name="key" direction="in"/>
<arg type="v" name="value" direction="out"/>
</method>
<signal name="SettingChanged">
<arg type="s" name="namespace"/>
<arg type="s" name="key"/>
<arg type="v" name="value"/>
</signal>
<property name="version" type="u" access="read"/>
</interface>
</node>
"""
NS = "org.freedesktop.appearance"
PATH = "/org/freedesktop/portal/desktop"
IFACE = "org.freedesktop.portal.Settings"
state = {}
def values():
return {
"accent-color": GLib.Variant("(ddd)", state["accent"]),
"color-scheme": GLib.Variant("u", state["scheme"]),
}
def parse(args):
r, g, b = (float(x) for x in args[:3])
return (r, g, b), int(args[3]) if len(args) > 3 else 0
def on_call(conn, sender, path, iface, method, params, inv):
if method == "ReadAll":
(namespaces,) = params.unpack()
want = not namespaces or any(
n == NS or (n.endswith("*") and NS.startswith(n[:-1])) or n == ""
for n in namespaces
)
inv.return_value(GLib.Variant("(a{sa{sv}})", ({NS: values()} if want else {},)))
return
ns, key = params.unpack()
v = values().get(key) if ns == NS else None
if v is None:
inv.return_dbus_error("org.freedesktop.portal.Error.NotFound", "no such setting")
elif method == "Read": # version 1 wraps the value in another variant
inv.return_value(GLib.Variant("(v)", (GLib.Variant("v", v),)))
else:
inv.return_value(GLib.Variant("(v)", (v,)))
def on_get(conn, sender, path, iface, prop):
return GLib.Variant("u", 2)
def main():
state["accent"], state["scheme"] = parse(sys.argv[1:])
loop = GLib.MainLoop()
bus = Gio.bus_get_sync(Gio.BusType.SESSION)
info = Gio.DBusNodeInfo.new_for_xml(XML).interfaces[0]
bus.register_object(PATH, info, on_call, on_get, None)
def on_stdin(ch, cond):
line = ch.readline()
if not line:
return False
state["accent"], state["scheme"] = parse(line.split())
for key, v in values().items():
bus.emit_signal(None, PATH, IFACE, "SettingChanged",
GLib.Variant("(ssv)", (NS, key, v)))
return True
GLib.io_add_watch(GLib.IOChannel.unix_new(0), GLib.IO_IN | GLib.IO_HUP, on_stdin)
Gio.bus_own_name_on_connection(
bus, "org.freedesktop.portal.Desktop", Gio.BusNameOwnerFlags.NONE,
lambda *_: print("fake portal: ready", flush=True),
lambda *_: (print("fake portal: name lost", flush=True), loop.quit()))
loop.run()
if __name__ == "__main__":
main()
+36 -4
View File
@@ -2,7 +2,8 @@
# Headless smoke test: start a private PipeWire + WirePlumber (two null # Headless smoke test: start a private PipeWire + WirePlumber (two null
# sinks, a loopback virtual microphone, a playback and a capture stream), # sinks, a loopback virtual microphone, a playback and a capture stream),
# run every moonmix-probe action and check its effect, then, if # run every moonmix-probe action and check its effect, then, if
# gtk4-broadwayd is available, render GUI screenshots. # gtk4-broadwayd is available, render GUI screenshots: with the theme's
# accent and, through a fake XDG Desktop Portal, with a system accent colour.
# #
# Only this *test harness* uses pw-cat (to create a playing stream); moonmix # Only this *test harness* uses pw-cat (to create a playing stream); moonmix
# itself talks to PipeWire through libwireplumber. # itself talks to PipeWire through libwireplumber.
@@ -60,7 +61,7 @@ CONF
PIDS="" PIDS=""
cleanup() { for p in $PIDS; do kill "$p" 2>/dev/null || true; done; [ -n "${KEEP:-}" ] || rm -rf "$XDG_RUNTIME_DIR"; } cleanup() { for p in $PIDS; do kill "$p" 2>/dev/null || true; done; [ -n "${KEEP:-}" ] || rm -rf "$XDG_RUNTIME_DIR"; }
trap cleanup EXIT INT TERM trap cleanup EXIT INT TERM PIPE
pipewire >"$XDG_RUNTIME_DIR/pipewire.log" 2>&1 & PIDS="$PIDS $!" pipewire >"$XDG_RUNTIME_DIR/pipewire.log" 2>&1 & PIDS="$PIDS $!"
sleep 1 sleep 1
@@ -156,8 +157,39 @@ if [ -n "$SHOTS" ] && [ -x "$GUI" ]; then
if command -v gtk4-broadwayd >/dev/null; then if command -v gtk4-broadwayd >/dev/null; then
gtk4-broadwayd :5 >/dev/null 2>&1 & PIDS="$PIDS $!" gtk4-broadwayd :5 >/dev/null 2>&1 & PIDS="$PIDS $!"
sleep 1 sleep 1
MOONMIX_ICON_DIR="$ROOT/data/icons" GDK_BACKEND=broadway BROADWAY_DISPLAY=:5 MOONMIX_SCREENSHOT="$SHOTS" \ gui() { MOONMIX_ICON_DIR="$ROOT/data/icons" GDK_BACKEND=broadway BROADWAY_DISPLAY=:5 timeout 30 stdbuf -oL "$GUI"; }
timeout 30 "$GUI" || fail=1 # Default look: no session bus, so no portal and the theme's own accent.
DBUS_SESSION_BUS_ADDRESS="unix:path=$XDG_RUNTIME_DIR/no-bus" MOONMIX_SCREENSHOT="$SHOTS" gui || fail=1
# System accent: a fake org.freedesktop.portal.Settings on a private
# session bus reports a green accent, then switches to orange while
# moonmix runs (SettingChanged); it takes the shots once orange is applied.
PY=""
for p in python3 /usr/bin/python3; do
if "$p" -c 'from gi.repository import Gio' 2>/dev/null; then PY=$p; break; fi
done
if [ -n "$PY" ] && command -v dbus-daemon >/dev/null; then
echo "### system accent colour (fake portal) -> $SHOTS-accent-<tab>.png"
dbus-daemon --session --nofork --address="unix:path=$XDG_RUNTIME_DIR/bus" \
>/dev/null 2>&1 & PIDS="$PIDS $!"
export DBUS_SESSION_BUS_ADDRESS="unix:path=$XDG_RUNTIME_DIR/bus"
for _ in $(seq 1 40); do [ -S "$XDG_RUNTIME_DIR/bus" ] && break; sleep 0.25; done
mkfifo "$LOGS/portal.in"
"$PY" "$ROOT/tools/fake-portal.py" 0.2 0.82 0.48 0 <"$LOGS/portal.in" >"$LOGS/portal.log" 2>&1 & PIDS="$PIDS $!"
exec 4>"$LOGS/portal.in"
for _ in $(seq 1 40); do grep -q ready "$LOGS/portal.log" 2>/dev/null && break; sleep 0.25; done
MOONMIX_SCREENSHOT="$SHOTS-accent" MOONMIX_SCREENSHOT_ACCENT="#ff7800" gui >"$LOGS/accent.log" 2>&1 & GUIPID=$!
for _ in $(seq 1 40); do grep -q 'accent #33d17a' "$LOGS/accent.log" && break; sleep 0.25; done
echo "1 0.471 0 0" >&4 || true
wait "$GUIPID" || fail=1
exec 4>&-
cat "$LOGS/accent.log"
if ! grep -q 'accent #33d17a, light' "$LOGS/accent.log" || ! grep -q 'accent #ff7800, light' "$LOGS/accent.log"; then
echo "FAIL: accent colour not read from the portal or not updated live"
cat "$LOGS/portal.log"; fail=1
fi
else
echo "python3 with gi or dbus-daemon not found; skipping the accent colour screenshots"
fi
else else
echo "gtk4-broadwayd not found; skipping GUI" echo "gtk4-broadwayd not found; skipping GUI"
fi fi