Dark mode for KDE/Qt apps: write kdeglobals colors and set QT_QPA_PLATFORMTHEME
CI / test (push) Failing after 17s
CI / test (push) Failing after 17s
KWrite stayed light with the Dark mode switch on. KDE apps read their colors from the [Colors:*] groups of kdeglobals, not from the scheme's name, and the switch only set [General] ColorScheme with kwriteconfig. Qt 6 apps also had no platform theme under XDG_CURRENT_DESKTOP=chandra, so Qt reported an unknown (light) color scheme whatever the portal said, and KDE Frameworks 6 apps picked Breeze Light. - session/chandra-kde-colors dark|light copies the scheme's color groups into kdeglobals (counterpart of the current scheme, else Breeze, else Chandra's own ChandraDark/ChandraLight) and emits KGlobalSettings.notifyChange so running apps repaint. The compositor calls it from the switch. - chandra-session sets QT_QPA_PLATFORMTHEME to kde (plasma-integration) or xdgdesktopportal when unset, and passes it to the activation environment. - install.py installs the script and the two color schemes. - scripts/test-kde-colors.sh tests the rewriting, and that a running KWrite turns dark live; docs/dark-mode.md explains it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DPL5hjmk6mgq6Gg5vgKfMp
This commit is contained in:
8 files changed
+523
-12
No files matched your search
+25
-2
@@ -35,6 +35,29 @@ export MOZ_ENABLE_WAYLAND=1
|
||||
export QT_QPA_PLATFORM=wayland
|
||||
export SDL_VIDEODRIVER=wayland
|
||||
|
||||
# Qt's platform theme decides where Qt apps get their palette from. With XDG_CURRENT_DESKTOP=chandra
|
||||
# Qt picks none of its desktop themes, so Qt 6 apps never saw the Dark mode switch (KDE Frameworks
|
||||
# 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.
|
||||
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
|
||||
for f in "$d"/platformthemes/$2; do [ -e "$f" ] && return 0; done
|
||||
done
|
||||
return 1
|
||||
}
|
||||
if [ -z "${QT_QPA_PLATFORMTHEME:-}" ]; then
|
||||
if qt_theme_plugin 6 'KDEPlasmaPlatformTheme6.so'; then
|
||||
export QT_QPA_PLATFORMTHEME=kde
|
||||
elif qt_theme_plugin 6 'libqxdgdesktopportal.so'; then
|
||||
export QT_QPA_PLATFORMTHEME=xdgdesktopportal
|
||||
elif qt_theme_plugin 5 'KDEPlasmaPlatformTheme*.so'; then
|
||||
export QT_QPA_PLATFORMTHEME=kde
|
||||
fi
|
||||
fi
|
||||
|
||||
mkdir -p "$HOME/.local/state/chandra"
|
||||
log="$HOME/.local/state/chandra/session.log"
|
||||
[ -n "$CHANDRA_SESSION_LOG_STARTED" ] || : >"$log"
|
||||
@@ -72,10 +95,10 @@ fi
|
||||
if command -v dbus-update-activation-environment >/dev/null 2>&1; then
|
||||
dbus-update-activation-environment --systemd \
|
||||
WAYLAND_DISPLAY="$(basename "$sock")" XDG_SESSION_TYPE XDG_CURRENT_DESKTOP \
|
||||
XDG_SESSION_DESKTOP >>"$log" 2>&1 ||
|
||||
XDG_SESSION_DESKTOP QT_QPA_PLATFORM QT_QPA_PLATFORMTHEME >>"$log" 2>&1 ||
|
||||
dbus-update-activation-environment \
|
||||
WAYLAND_DISPLAY="$(basename "$sock")" XDG_SESSION_TYPE XDG_CURRENT_DESKTOP \
|
||||
XDG_SESSION_DESKTOP >>"$log" 2>&1 || true
|
||||
XDG_SESSION_DESKTOP QT_QPA_PLATFORM QT_QPA_PLATFORMTHEME >>"$log" 2>&1 || true
|
||||
fi
|
||||
|
||||
# xdg-desktop-portal picks its backends once, at start, from $XDG_CURRENT_DESKTOP (here
|
||||
|
||||
Reference in new issue
Block a user