From 540377745137da65a09d809a558ca9a24f4621b2 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 26 Nov 2026 01:43:01 +0000 Subject: [PATCH] Session: replace a Qt platform theme whose plugin isn't installed 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 Claude-Session: https://claude.ai/code/session_01DPL5hivwxSsQ56aGGv4cFQ --- docs/dark-mode.md | 4 +++- session/chandra-session | 22 +++++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/docs/dark-mode.md b/docs/dark-mode.md index 4570f3a..20b21a4 100644 --- a/docs/dark-mode.md +++ b/docs/dark-mode.md @@ -40,7 +40,9 @@ So now: Chandra's own `ChandraDark` / `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-session` sets `QT_QPA_PLATFORMTHEME`, unless you set it yourself (qt6ct, say): `kde` +- `chandra-session` sets `QT_QPA_PLATFORMTHEME`, unless you set it yourself (qt6ct, say) to a + theme whose plugin is installed (a leftover `gnome` without QGnomePlatform is replaced: Qt then + loads no theme, and Dolphin mixes a light palette with dark kdeglobals rows): `kde` when KDE's platform theme is installed (package `plasma-integration`; it reads kdeglobals and repaints live when the switch flips), else `xdgdesktopportal` (Qt 6.5+ follows the portal's color-scheme; KDE Frameworks 6 apps then load Breeze Dark/Light, which need the `breeze` color diff --git a/session/chandra-session b/session/chandra-session index ff27ea3..bbb305b 100755 --- a/session/chandra-session +++ b/session/chandra-session @@ -59,7 +59,10 @@ export SDL_VIDEODRIVER=wayland # 6 apps such as KWrite then pick Breeze Light). Prefer KDE's own (plasma-integration: reads the # kdeglobals colors chandra-kde-colors writes and repaints live when the switch flips), else Qt's # xdgdesktopportal theme (Qt 6.5+ follows the portal's color-scheme, which the compositor serves, -# and KDE Frameworks apps then pick Breeze Dark/Light). A value set elsewhere (qt6ct, say) wins. +# and KDE Frameworks apps then pick Breeze Dark/Light). A value set elsewhere (qt6ct, say) wins, +# unless its plugin isn't installed: QT_QPA_PLATFORMTHEME=gnome left over from a GNOME setup +# without QGnomePlatform makes Qt load no theme at all, and Dolphin then mixes a light palette with +# the dark kdeglobals colors (near-black rows with dark text). qt_theme_plugin() { # QT_MAJOR GLOB -> success if a platform theme plugin matching GLOB exists for d in /usr/lib/qt$1/plugins /usr/lib64/qt$1/plugins /usr/lib/*-linux-gnu*/qt$1/plugins \ /usr/lib/qt/plugins /usr/lib64/qt/plugins /usr/local/lib/qt$1/plugins; do @@ -67,6 +70,23 @@ qt_theme_plugin() { # QT_MAJOR GLOB -> success if a platform theme plugin match done return 1 } +qt_theme_installed() { # KEY -> failure if we know KEY's plugin and it is installed for neither Qt + case "$1" in + kde) g='KDEPlasmaPlatformTheme*.so' ;; + xdgdesktopportal|flatpak|snap) g='libqxdgdesktopportal.so' ;; + gtk3) g='libqgtk3.so' ;; + gnome) g='*gnomeplatform*.so' ;; + lxqt) g='libqtlxqt.so' ;; + qt6ct) g='libqt6ct.so' ;; + qt5ct) g='libqt5ct.so' ;; + *) return 0 ;; # a theme we don't know: trust it + esac + qt_theme_plugin 6 "$g" || qt_theme_plugin 5 "$g" +} +if [ -n "${QT_QPA_PLATFORMTHEME:-}" ] && ! qt_theme_installed "$QT_QPA_PLATFORMTHEME"; then + echo "chandra-session: QT_QPA_PLATFORMTHEME=$QT_QPA_PLATFORMTHEME has no plugin installed; picking one" >&2 + unset QT_QPA_PLATFORMTHEME +fi if [ -z "${QT_QPA_PLATFORMTHEME:-}" ]; then if qt_theme_plugin 6 'KDEPlasmaPlatformTheme6.so'; then export QT_QPA_PLATFORMTHEME=kde