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
@@ -8,10 +8,11 @@
|
||||
/// between Adwaita and Adwaita-dark for GTK 3 apps (and Chrome's GTK mode), but only when it is
|
||||
/// one of those two, so a hand-picked theme is left alone. `gtk-application-prefer-dark-theme`
|
||||
/// in $XDG_CONFIG_HOME/gtk-{3,4}.0/settings.ini covers systems without gsettings.
|
||||
/// - Qt / KDE: apps using KDE's color schemes read kdeglobals. `plasma-apply-colorscheme
|
||||
/// BreezeDark|BreezeLight` rewrites it when Plasma's tools are installed, else kwriteconfig6/5
|
||||
/// sets [General] ColorScheme. qt6ct/qt5ct users whose color file is a light/dark variant get
|
||||
/// the other one.
|
||||
/// - Qt / KDE: KDE apps (KWrite, Kate, Dolphin) take their colors from the [Colors:*] groups of
|
||||
/// kdeglobals, not from the scheme's name. `chandra-kde-colors dark|light` (session/) copies a
|
||||
/// dark or light scheme's colors in and tells running apps to repaint; see docs/dark-mode.md.
|
||||
/// Without it (not installed) kwriteconfig6/5 only sets [General] ColorScheme, as before.
|
||||
/// qt6ct/qt5ct users whose color file is a light/dark variant get the other one.
|
||||
///
|
||||
/// Only the login session (--drm) does this: a nested Chandra window must not restyle the desktop
|
||||
/// it runs in. Missing tools are skipped silently.
|
||||
@@ -37,8 +38,9 @@ let system_theme_script : String =
|
||||
#| printf '[Settings]\n%s=@V@\n' "$k" >> "$f"
|
||||
#| fi
|
||||
#|done
|
||||
#|if command -v plasma-apply-colorscheme >/dev/null 2>&1; then
|
||||
#| plasma-apply-colorscheme @KDE@ >/dev/null 2>&1
|
||||
#|kc=$(command -v chandra-kde-colors || echo /usr/local/bin/chandra-kde-colors)
|
||||
#|if [ -x "$kc" ]; then
|
||||
#| "$kc" @MODE@ >/dev/null
|
||||
#|else
|
||||
#| for w in kwriteconfig6 kwriteconfig5; do
|
||||
#| if command -v $w >/dev/null 2>&1; then
|
||||
@@ -63,6 +65,7 @@ pub fn system_theme_command(dark : Bool) -> String {
|
||||
("@GTK@", if dark { "Adwaita-dark" } else { "Adwaita" }),
|
||||
("@V@", if dark { "1" } else { "0" }),
|
||||
("@KDE@", if dark { "BreezeDark" } else { "BreezeLight" }),
|
||||
("@MODE@", if dark { "dark" } else { "light" }),
|
||||
("@FROM@", if dark { "light" } else { "dark" }),
|
||||
("@TO@", if dark { "dark" } else { "light" }),
|
||||
]
|
||||
@@ -112,13 +115,14 @@ test "the system theme command sets the GTK, portal and Qt/KDE preferences" {
|
||||
assert_true(d.contains("color-scheme prefer-dark"))
|
||||
assert_true(d.contains("gtk-theme Adwaita-dark"))
|
||||
assert_true(d.contains("$k=1"))
|
||||
assert_true(d.contains("plasma-apply-colorscheme BreezeDark"))
|
||||
assert_true(d.contains("\"$kc\" dark"))
|
||||
assert_true(d.contains("--key ColorScheme BreezeDark"))
|
||||
assert_false(d.contains("@"))
|
||||
let l = system_theme_command(false)
|
||||
assert_true(l.contains("color-scheme default"))
|
||||
assert_true(l.contains("gtk-theme Adwaita ;"))
|
||||
assert_true(l.contains("$k=0"))
|
||||
assert_true(l.contains("plasma-apply-colorscheme BreezeLight"))
|
||||
assert_true(l.contains("\"$kc\" light"))
|
||||
assert_true(l.contains("--key ColorScheme BreezeLight"))
|
||||
assert_true(l.contains("s/dark/light/I"))
|
||||
}
|
||||
Reference in new issue
Block a user