Chrome follows the Dark mode switch: Chandra serves the portal's color-scheme
CI / test (push) Failing after 17s
CI / test (push) Failing after 17s
Chrome (and Firefox, Electron, GTK 4, Qt 6) read dark/light from xdg-desktop-portal's Settings
interface. With XDG_CURRENT_DESKTOP=chandra and no chandra-portals.conf, xdg-desktop-portal found
no Settings backend (gtk/gnome are UseIn=gnome, kde is UseIn=KDE) and exported no Settings
interface at all, so the gsettings color-scheme a790901 sets never reached Chrome.
- compositor/portal: the compositor is an org.freedesktop.impl.portal.Settings backend
(org.freedesktop.impl.portal.desktop.chandra on the session bus): Read/ReadAll of
org.freedesktop.appearance color-scheme (1 dark, 2 light), SettingChanged when the switch flips,
version property, introspection. Login session only; the main loop wakes on its socket.
- compositor/network/dbus.mbt: serve calls (on_call, reply, reply_error), emit and receive
signals, sender field, session bus address.
- session/chandra.portal + chandra-portals.conf, installed to /usr/share/xdg-desktop-portal by
install.py: Settings from chandra first, then gtk/kde/gnome; other portals from gtk/kde/gnome.
- chandra-session restarts a running xdg-desktop-portal so it reads the config for this desktop.
- scripts/test-portal-dbus.sh: end to end behind the real xdg-desktop-portal on a private bus
(ReadOne gives 1, flipping gives SettingChanged 2). docs/dark-mode.md: how to check it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hhkztRQM7vcSuHX4bB
This commit is contained in:
14 files changed
+739
-5
No files matched your search
@@ -0,0 +1,42 @@
|
||||
# Dark mode for apps
|
||||
|
||||
The Settings module's **Dark mode** switch restyles Chandra itself and, in the login session
|
||||
(`chandra-session`, `--drm`), tells apps:
|
||||
|
||||
- **xdg-desktop-portal Settings** (Chrome/Chromium, Electron, Firefox, GTK 4 / libadwaita,
|
||||
Qt 6.5+): the compositor is a portal backend itself (`compositor/portal`). It owns
|
||||
`org.freedesktop.impl.portal.desktop.chandra` on the session bus and answers
|
||||
`org.freedesktop.appearance color-scheme` (1 dark, 2 light), emitting `SettingChanged` when the
|
||||
switch flips, so open apps follow live.
|
||||
`session/chandra.portal` and `session/chandra-portals.conf` (installed to
|
||||
`/usr/share/xdg-desktop-portal/` by `session/install.py`) point xdg-desktop-portal at it.
|
||||
- gsettings `color-scheme` / `gtk-theme`, GTK 3/4 `settings.ini`, KDE color scheme and qt5ct/qt6ct
|
||||
(`compositor/host/system_theme.mbt`), for apps that read those instead.
|
||||
|
||||
## Why Chrome ignored the switch before
|
||||
|
||||
xdg-desktop-portal chooses backends from `$XDG_CURRENT_DESKTOP-portals.conf`, then the backends'
|
||||
`UseIn=` keys. The session sets `XDG_CURRENT_DESKTOP=chandra` and there was no
|
||||
`chandra-portals.conf`; GTK's and GNOME's backends say `UseIn=gnome`, KDE's `UseIn=KDE`. So
|
||||
xdg-desktop-portal (1.18, as in Ubuntu 24.04) exported no Settings interface at all, and Chrome,
|
||||
which asks the portal, never saw the preference that gsettings held.
|
||||
|
||||
## Checking it on your machine
|
||||
|
||||
After reinstalling (`just install-session`) and logging in to Chandra again:
|
||||
|
||||
```sh
|
||||
# 1 = dark, 2 = light; flip the switch and run it again
|
||||
gdbus call --session -d org.freedesktop.portal.Desktop -o /org/freedesktop/portal/desktop \
|
||||
-m org.freedesktop.portal.Settings.ReadOne org.freedesktop.appearance color-scheme
|
||||
# the backend itself
|
||||
busctl --user status org.freedesktop.impl.portal.desktop.chandra
|
||||
```
|
||||
|
||||
- xdg-desktop-portal must be installed (`xdg-desktop-portal` package). It reads its config only
|
||||
when it starts: `chandra-session` restarts it at login, or run
|
||||
`systemctl --user restart xdg-desktop-portal`.
|
||||
- In Chrome, Settings > Appearance > Mode must be **Device** (a fixed Light or Dark there wins).
|
||||
Pages follow through `prefers-color-scheme`; Chrome's own UI follows too.
|
||||
- `scripts/test-portal-dbus.sh` runs the backend behind the real xdg-desktop-portal on a private
|
||||
bus (what CI-less checks can do without a desktop).
|
||||
Reference in new issue
Block a user