QT_QPA_PLATFORMTHEME=gnome left in the environment without QGnomePlatform made Qt load no platform theme, so KF6 apps got a light Breeze palette while the Breeze style and Dolphin's view read the dark kdeglobals colors: Dolphin's rows alternated near-black (with dark text) and light. chandra-session now keeps a preset theme only if its plugin exists for Qt 6 or 5, else picks kde / xdgdesktopportal as before. Reproduced and checked with Dolphin 26.08 / Qt 6.11 / KF 6.32 headless. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DPL5hivwxSsQ56aGGv4cFQ
5.5 KiB
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 ownsorg.freedesktop.impl.portal.desktop.chandraon the session bus and answersorg.freedesktop.appearance color-scheme(1 dark, 2 light), emittingSettingChangedwhen the switch flips, so open apps follow live.session/chandra.portalandsession/chandra-portals.conf(installed to/usr/share/xdg-desktop-portal/bysession/install.py) point xdg-desktop-portal at it. - KDE / Qt apps (KWrite, Kate, Dolphin, Okular):
chandra-kde-colors dark|light(fromcompositor/host/system_theme.mbt) copies a dark or light color scheme's[Colors:*]groups into~/.config/kdeglobalsand sendsorg.kde.KGlobalSettings.notifyChange, so open apps repaint.chandra-sessionsetsQT_QPA_PLATFORMTHEME(see below). - gsettings
color-scheme/gtk-theme, GTK 3/4settings.iniand qt5ct/qt6ct, for apps that read those instead.
Why KWrite stayed light
Two things, depending on the KDE Frameworks version:
- KDE apps don't load a color scheme by its name.
KColorSchemereads the colors themselves from the[Colors:Window],[Colors:View], ... groups ofkdeglobals, which Plasma's System Settings (orplasma-apply-colorscheme) copies in from the scheme's.colorsfile. Chandra only set[General] ColorScheme=BreezeDarkwith kwriteconfig, so the groups stayed light, or missing (then apps use their built-in light colors). Reproduced in the cloud with KWrite 23.08: light with only the name, dark once the groups are there. - Qt 6 / KDE Frameworks 6 apps outside Plasma pick Breeze Dark or Breeze Light from Qt's
styleHints()->colorScheme(). Qt only knows that from a platform theme, and withXDG_CURRENT_DESKTOP=chandraandQT_QPA_PLATFORMTHEMEunset it loads none of them, so the answer was always "unknown" (light), whatever the portal said. Checked with Qt 6.12: unset givesUnknown,xdgdesktopportalgivesDarkand follows the switch live.
So now:
chandra-kde-colorswrites the full color groups. The scheme is the dark/light counterpart of the current one when it exists (FooLight<->FooDark), else Breeze Dark / Breeze Light, else Chandra's ownChandraDark/ChandraLight(session/color-schemes, installed to/usr/local/share/color-schemes, from the Moon Night / Moon Day palettes). Other kdeglobals settings (fonts, icons) are kept.chandra-sessionsetsQT_QPA_PLATFORMTHEME, unless you set it yourself (qt6ct, say) to a theme whose plugin is installed (a leftovergnomewithout QGnomePlatform is replaced: Qt then loads no theme, and Dolphin mixes a light palette with dark kdeglobals rows):kdewhen KDE's platform theme is installed (packageplasma-integration; it reads kdeglobals and repaints live when the switch flips), elsexdgdesktopportal(Qt 6.5+ follows the portal's color-scheme; KDE Frameworks 6 apps then load Breeze Dark/Light, which need thebreezecolor schemes installed). It also passes it to D-Bus/systemd-activated apps.
Best results: install plasma-integration (it brings the Breeze style and color schemes). Without
it, Qt 5 / KDE Frameworks 5 apps still come up in the right colors but only pick up a flip when
restarted.
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:
# 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-portalpackage). It reads its config only when it starts:chandra-sessionrestarts it at login, or runsystemctl --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. -
KDE / Qt apps:
echo $QT_QPA_PLATFORMTHEME # kde or xdgdesktopportal head -n 20 ~/.config/kdeglobals # [General] ColorScheme=..., then [Colors:*] groups chandra-kde-colors dark # by hand: prints the scheme it applied ls /usr/share/color-schemes # BreezeDark.colors etc. (package breeze / plasma-integration) kwrite --versionApps started before you logged in again keep the old
QT_QPA_PLATFORMTHEME; restart them. -
scripts/test-kde-colors.shchecks the kdeglobals rewriting and, withkwrite,plasma-integration,xvfband ImageMagick installed, that a running KWrite turns dark. -
scripts/test-portal-dbus.shruns the backend behind the real xdg-desktop-portal on a private bus (what CI-less checks can do without a desktop).