Session: replace a Qt platform theme whose plugin isn't installed
CI / test (push) Successful in 2m10s

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
This commit is contained in:
Claude committed 2026-11-26 01:43:02 +00:00
1 parent 3e35c4dfa5
commit 5403777451
2 files changed
+24 -2

No files matched your search

+3 -1
View File
@@ -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
+21 -1
View File
@@ -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