Builds on #2 (geordi/better-icons, not merged yet): this branch starts from it, so until #2 is merged the diff here also shows #2's commits. Only the last commit (74d85ec) is new.
moonmix now follows the desktop's accent colour and dark/light preference, and updates live when you change them in system settings.
Approach: XDG Desktop Portal directly, not libadwaita
The GTK stub reads org.freedesktop.appearance → accent-color ((ddd), 0..1) and color-scheme (0/1/2) with one async ReadAll on org.freedesktop.portal.Settings over GDBus. It also subscribes to SettingChanged. GNOME 47+, KDE Plasma 6 and others implement this. Nothing is shelled out.
Why not libadwaita:AdwStyleManager would do the same on 1.6+, but it means a new dependency, a move from the plain GMainLoop to AdwApplication, and a switch from GTK's standard look to Adwaita styling everywhere. The portal route is about 150 lines of C. It keeps the current look and works with any GTK 4.12+.
Fallback: with no session bus, no portal, or no accent set (out-of-range values, as GNOME sends before you pick one), moonmix installs no accent CSS and the theme's own accent stays. If the setting is later unset, the CSS is removed again.
How it's applied
A GtkCssProvider at APPLICATION priority, replaced on every change, sets:
the named colours accent_bg_color, accent_fg_color, accent_color and theme_selected_bg/fg_color, plus the --accent-* variables, for themes that use them;
explicit rules for the selected tab underline, the slider fill, the peak-meter fill, the checked Default button, check/radio/switch, selected rows, links and focus rings. These are needed because GTK 4's built-in Default theme hardcodes #3584e4 and ignores the named colours.
color-scheme sets gtk-application-prefer-dark-theme, plus gtk-interface-color-scheme on GTK 4.20+. "No preference" restores what was configured before.
Pure model (model/accent.mbt, 7 new tests, 34 in total, all pass)
Converts the portal tuple to a colour (rejecting unset or NaN values), parses and formats #rrggbb, and computes WCAG luminance and contrast ratio.
readable_fg: text and icons on the accent are white while that reaches 3:1, as GTK and libadwaita do; otherwise whichever of black and white contrasts more. That gives black on orange, yellow and light green.
accent_text_color: the accent used as a text colour is darkened (light theme) or lightened (dark theme) until it reaches 4.5:1 on the window background.
accent_css generates the stylesheet.
Smoke test
tools/smoke-test.sh now renders the tabs twice:
Default: with no session bus. These screenshots are byte-identical to before except for the meter frame.
Accent:tools/fake-portal.py (python3-gi) serves org.freedesktop.portal.Settings on a private dbus-daemon. It starts with a green accent and then emits SettingChanged to orange while moonmix runs. The test checks that moonmix logged accent #33d17a (initial read) and then accent #ff7800 (live update). With MOONMIX_SCREENSHOT_ACCENT, moonmix takes the shots only once orange is applied.
CI installs dbus-daemon python3-gi gir1.2-glib-2.0. Without them, the script skips the accent shots.
Default
Playback
Recording
Output Devices
Input Devices
Orange system accent (live update via fake portal)
Playback
Recording
Output Devices
Input Devices
Not covered by a screenshot: the dark colour-scheme path. It is unit-tested on the model side and type-checked, but not rendered.
**Builds on #2** (`geordi/better-icons`, not merged yet): this branch starts from it, so until #2 is merged the diff here also shows #2's commits. Only the last commit (74d85ec) is new.
moonmix now follows the desktop's **accent colour** and **dark/light preference**, and updates live when you change them in system settings.
## Approach: XDG Desktop Portal directly, not libadwaita
- The GTK stub reads `org.freedesktop.appearance` → `accent-color` (`(ddd)`, 0..1) and `color-scheme` (0/1/2) with one async `ReadAll` on `org.freedesktop.portal.Settings` over GDBus. It also subscribes to `SettingChanged`. GNOME 47+, KDE Plasma 6 and others implement this. Nothing is shelled out.
- **Why not libadwaita:** `AdwStyleManager` would do the same on 1.6+, but it means a new dependency, a move from the plain GMainLoop to `AdwApplication`, and a switch from GTK's standard look to Adwaita styling everywhere. The portal route is about 150 lines of C. It keeps the current look and works with any GTK 4.12+.
- **Fallback:** with no session bus, no portal, or no accent set (out-of-range values, as GNOME sends before you pick one), moonmix installs no accent CSS and the theme's own accent stays. If the setting is later unset, the CSS is removed again.
## How it's applied
- A `GtkCssProvider` at APPLICATION priority, replaced on every change, sets:
- the named colours `accent_bg_color`, `accent_fg_color`, `accent_color` and `theme_selected_bg/fg_color`, plus the `--accent-*` variables, for themes that use them;
- explicit rules for the selected tab underline, the slider fill, the peak-meter fill, the checked *Default* button, check/radio/switch, selected rows, links and focus rings. These are needed because GTK 4's built-in Default theme hardcodes `#3584e4` and ignores the named colours.
- `color-scheme` sets `gtk-application-prefer-dark-theme`, plus `gtk-interface-color-scheme` on GTK 4.20+. "No preference" restores what was configured before.
## Pure model (`model/accent.mbt`, 7 new tests, 34 in total, all pass)
- Converts the portal tuple to a colour (rejecting unset or NaN values), parses and formats `#rrggbb`, and computes WCAG luminance and contrast ratio.
- `readable_fg`: text and icons on the accent are white while that reaches 3:1, as GTK and libadwaita do; otherwise whichever of black and white contrasts more. That gives black on orange, yellow and light green.
- `accent_text_color`: the accent used as a text colour is darkened (light theme) or lightened (dark theme) until it reaches 4.5:1 on the window background.
- `accent_css` generates the stylesheet.
## Smoke test
`tools/smoke-test.sh` now renders the tabs twice:
- **Default:** with no session bus. These screenshots are byte-identical to before except for the meter frame.
- **Accent:** `tools/fake-portal.py` (python3-gi) serves `org.freedesktop.portal.Settings` on a private `dbus-daemon`. It starts with a green accent and then emits `SettingChanged` to orange while moonmix runs. The test checks that moonmix logged `accent #33d17a` (initial read) and then `accent #ff7800` (live update). With `MOONMIX_SCREENSHOT_ACCENT`, moonmix takes the shots only once orange is applied.
CI installs `dbus-daemon python3-gi gir1.2-glib-2.0`. Without them, the script skips the accent shots.
### Default
| Playback | Recording |
| --- | --- |
|  |  |
| **Output Devices** | **Input Devices** |
|  |  |
### Orange system accent (live update via fake portal)
| Playback | Recording |
| --- | --- |
|  |  |
| **Output Devices** | **Input Devices** |
|  |  |
Not covered by a screenshot: the dark colour-scheme path. It is unit-tested on the model side and type-checked, but not rendered.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
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>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Builds on #2 (
geordi/better-icons, not merged yet): this branch starts from it, so until #2 is merged the diff here also shows #2's commits. Only the last commit (74d85ec) is new.moonmix now follows the desktop's accent colour and dark/light preference, and updates live when you change them in system settings.
Approach: XDG Desktop Portal directly, not libadwaita
org.freedesktop.appearance→accent-color((ddd), 0..1) andcolor-scheme(0/1/2) with one asyncReadAllonorg.freedesktop.portal.Settingsover GDBus. It also subscribes toSettingChanged. GNOME 47+, KDE Plasma 6 and others implement this. Nothing is shelled out.AdwStyleManagerwould do the same on 1.6+, but it means a new dependency, a move from the plain GMainLoop toAdwApplication, and a switch from GTK's standard look to Adwaita styling everywhere. The portal route is about 150 lines of C. It keeps the current look and works with any GTK 4.12+.How it's applied
GtkCssProviderat APPLICATION priority, replaced on every change, sets:accent_bg_color,accent_fg_color,accent_colorandtheme_selected_bg/fg_color, plus the--accent-*variables, for themes that use them;#3584e4and ignores the named colours.color-schemesetsgtk-application-prefer-dark-theme, plusgtk-interface-color-schemeon GTK 4.20+. "No preference" restores what was configured before.Pure model (
model/accent.mbt, 7 new tests, 34 in total, all pass)#rrggbb, and computes WCAG luminance and contrast ratio.readable_fg: text and icons on the accent are white while that reaches 3:1, as GTK and libadwaita do; otherwise whichever of black and white contrasts more. That gives black on orange, yellow and light green.accent_text_color: the accent used as a text colour is darkened (light theme) or lightened (dark theme) until it reaches 4.5:1 on the window background.accent_cssgenerates the stylesheet.Smoke test
tools/smoke-test.shnow renders the tabs twice:tools/fake-portal.py(python3-gi) servesorg.freedesktop.portal.Settingson a privatedbus-daemon. It starts with a green accent and then emitsSettingChangedto orange while moonmix runs. The test checks that moonmix loggedaccent #33d17a(initial read) and thenaccent #ff7800(live update). WithMOONMIX_SCREENSHOT_ACCENT, moonmix takes the shots only once orange is applied.CI installs
dbus-daemon python3-gi gir1.2-glib-2.0. Without them, the script skips the accent shots.Default
Orange system accent (live update via fake portal)
Not covered by a screenshot: the dark colour-scheme path. It is unit-tested on the model side and type-checked, but not rendered.
🤖 Generated with Claude Code