Follow the desktop accent colour and colour scheme (XDG portal)
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:
1 parent
bc675459d9
commit
74d85ecdfc
16 files changed
+947
-12
No files matched your search
@@ -15,7 +15,11 @@ on top of libpipewire-0.3. It never runs `wpctl`, `pactl`, `pw-cli`,
|
||||
|  |  |
|
||||
|
||||
*(Rendered headlessly against a private PipeWire with null sinks; see
|
||||
[Testing](#testing).)*
|
||||
[Testing](#testing).)* With an orange system accent colour:
|
||||
|
||||
| Playback | Output Devices |
|
||||
| --- | --- |
|
||||
|  |  |
|
||||
|
||||
## 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
|
||||
PipeWire's linear `channelVolumes`, up to 150%, with the dB value next to
|
||||
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
|
||||
elsewhere (another mixer, keyboard volume keys, a new Bluetooth headset)
|
||||
show up immediately.
|
||||
@@ -88,6 +94,34 @@ flowchart LR
|
||||
time after the user moves a slider, remote updates to that slider are
|
||||
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
|
||||
|
||||
### 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 check --target native # type-check everything
|
||||
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
|
||||
@@ -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
|
||||
meters on the stream and its sink see the signal,
|
||||
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.
|
||||
It runs the native build and the smoke test in a `debian:trixie` container,
|
||||
|
||||
Reference in new issue
Block a user