Files
chandra/docs/dark-mode.md
T
Claude 4437a3a576
CI / test (push) Failing after 16s
Rename just install-session to just install
install-session(-dev/-rust/-native) become install(-dev/-rust/-native) and
uninstall-session becomes uninstall, so installing is just `just install`.
The old names stay as hidden recipes that print a one-line note and run the
new one. Docs, scripts and comments now point at the new names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hj5zRiffcgWaggHdjv
2026-11-25 22:17:05 +00:00

43 lines
2.3 KiB
Markdown

# 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`) 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).