diff --git a/compositor/host/system_theme.mbt b/compositor/host/system_theme.mbt index 29d191a..100aeae 100644 --- a/compositor/host/system_theme.mbt +++ b/compositor/host/system_theme.mbt @@ -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")) } diff --git a/docs/dark-mode.md b/docs/dark-mode.md index a69c211..4570f3a 100644 --- a/docs/dark-mode.md +++ b/docs/dark-mode.md @@ -10,8 +10,45 @@ The Settings module's **Dark mode** switch restyles Chandra itself and, in the l switch flips, so open apps follow live. `session/chandra.portal` and `session/chandra-portals.conf` (installed to `/usr/share/xdg-desktop-portal/` by `session/install.py`) point xdg-desktop-portal at it. -- gsettings `color-scheme` / `gtk-theme`, GTK 3/4 `settings.ini`, KDE color scheme and qt5ct/qt6ct - (`compositor/host/system_theme.mbt`), for apps that read those instead. +- **KDE / Qt apps** (KWrite, Kate, Dolphin, Okular): `chandra-kde-colors dark|light` (from + `compositor/host/system_theme.mbt`) copies a dark or light color scheme's `[Colors:*]` groups + into `~/.config/kdeglobals` and sends `org.kde.KGlobalSettings.notifyChange`, so open apps + repaint. `chandra-session` sets `QT_QPA_PLATFORMTHEME` (see below). +- gsettings `color-scheme` / `gtk-theme`, GTK 3/4 `settings.ini` and 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. `KColorScheme` reads the colors themselves from + the `[Colors:Window]`, `[Colors:View]`, ... groups of `kdeglobals`, which Plasma's System Settings + (or `plasma-apply-colorscheme`) copies in from the scheme's `.colors` file. Chandra only set + `[General] ColorScheme=BreezeDark` with 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 with + `XDG_CURRENT_DESKTOP=chandra` and `QT_QPA_PLATFORMTHEME` unset it loads none of them, so the + answer was always "unknown" (light), whatever the portal said. Checked with Qt 6.12: unset gives + `Unknown`, `xdgdesktopportal` gives `Dark` and follows the switch live. + +So now: + +- `chandra-kde-colors` writes 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 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` + 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 + 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 @@ -38,5 +75,18 @@ busctl --user status org.freedesktop.impl.portal.desktop.chandra `systemctl --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: + + ```sh + 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 --version + ``` + + Apps started before you logged in again keep the old `QT_QPA_PLATFORMTHEME`; restart them. +- `scripts/test-kde-colors.sh` checks the kdeglobals rewriting and, with `kwrite`, + `plasma-integration`, `xvfb` and ImageMagick installed, that a running KWrite turns dark. - `scripts/test-portal-dbus.sh` runs the backend behind the real xdg-desktop-portal on a private bus (what CI-less checks can do without a desktop). diff --git a/scripts/test-kde-colors.sh b/scripts/test-kde-colors.sh new file mode 100755 index 0000000..274de3e --- /dev/null +++ b/scripts/test-kde-colors.sh @@ -0,0 +1,74 @@ +#!/usr/bin/env bash +# Test session/chandra-kde-colors, the Dark mode switch's KDE/Qt part (docs/dark-mode.md). +# +# 1. kdeglobals handling, with no KDE packages needed: the scheme's color groups replace the old +# ones, other groups and keys stay, ColorScheme is set, Chandra's own schemes are the fallback, +# a FooLight/FooDark pair is kept. +# 2. With kwrite, Xvfb and ImageMagick installed (apt: kwrite plasma-integration xvfb imagemagick +# dbus), the real thing: KWrite starts light, the script flips it, and with the KDE platform +# theme (QT_QPA_PLATFORMTHEME=kde) the running window turns dark. Skipped when they're missing. +set -euo pipefail +ROOT="$(cd "$(dirname "$0")/.." && pwd)" +KC="$ROOT/session/chandra-kde-colors" +tmp=$(mktemp -d); trap 'rm -rf "$tmp"' EXIT +fail() { echo "FAIL: $*" >&2; exit 1; } +mkdir -p "$tmp/data/color-schemes" "$tmp/cfg" +cp "$ROOT"/session/color-schemes/*.colors "$tmp/data/color-schemes/" +run() { XDG_CONFIG_HOME="$tmp/cfg" XDG_DATA_HOME="$tmp/none" XDG_DATA_DIRS="$tmp/data" "$KC" "$@"; } +kg="$tmp/cfg/kdeglobals" +val() { sed -n "/^\[$1\]\$/,/^\[/s/^$2=//p" "$kg" | head -n 1; } + +# No kdeglobals yet, no Breeze: Chandra's schemes. +[ "$(run dark)" = ChandraDark ] || fail "dark without Breeze should pick ChandraDark" +[ "$(val General ColorScheme)" = ChandraDark ] || fail "ColorScheme not set" +[ "$(val Colors:Window BackgroundNormal)" = 31,41,55 ] || fail "Colors:Window not copied" +[ "$(val WM activeBackground)" = 31,41,55 ] || fail "WM not copied" + +# Existing settings survive; stale colors are replaced, not duplicated. +printf '[General]\nColorScheme=BreezeLight\nfont=Sans,10\n\n[Colors:Window]\nBackgroundNormal=1,2,3\nStale=1\n\n[Icons]\nTheme=breeze\n' >"$kg" +run dark >/dev/null +[ "$(val General font)" = Sans,10 ] || fail "[General] font lost" +[ "$(val Icons Theme)" = breeze ] || fail "[Icons] lost" +grep -q '^Stale=' "$kg" && fail "old color group kept" +[ "$(grep -c '^\[Colors:Window\]' "$kg")" = 1 ] || fail "Colors:Window duplicated" +[ "$(grep -c '^ColorScheme=' "$kg")" = 1 ] || fail "ColorScheme duplicated" +run light >/dev/null +[ "$(val General ColorScheme)" = ChandraLight ] || fail "light" +[ "$(val Colors:View BackgroundNormal)" = 255,255,255 ] || fail "light colors" + +# A dark/light pair of the user's own is kept: MyLight -> MyDark. +sed 's/^ColorScheme=.*/ColorScheme=MyDark/; s/^BackgroundNormal=17,24,39/BackgroundNormal=9,9,9/' \ + "$tmp/data/color-schemes/ChandraDark.colors" >"$tmp/data/color-schemes/MyDark.colors" +sed -i 's/^ColorScheme=.*/ColorScheme=MyLight/' "$kg" +[ "$(run dark)" = MyDark ] || fail "MyLight should become MyDark" +[ "$(val Colors:View BackgroundNormal)" = 9,9,9 ] || fail "MyDark colors" +# No kdeglobals [General] at all. +printf '[Icons]\nTheme=breeze\n' >"$kg" +run dark >/dev/null +[ "$(val General ColorScheme)" = ChandraDark ] || fail "[General] not added" +run bogus 2>/dev/null && fail "bad argument accepted" +echo "kdeglobals: ok" + +# 2. Real KWrite. +for c in kwrite Xvfb import convert dbus-run-session; do + command -v $c >/dev/null 2>&1 || { echo "skipping the KWrite check ($c not installed)"; exit 0; } +done +export XDG_CONFIG_HOME="$tmp/kw" HOME="$tmp/kw/home" DISPLAY=:77 QT_QPA_PLATFORM=xcb \ + QT_QPA_PLATFORMTHEME=kde KC tmp +mkdir -p "$HOME" +Xvfb :77 -screen 0 800x600x24 >/dev/null 2>&1 & xvfb=$! +trap 'kill $xvfb 2>/dev/null; rm -rf "$tmp"' EXIT +sleep 1 +dbus-run-session -- sh -c ' + "$KC" light >/dev/null + kwrite >/dev/null 2>&1 & k=$! + sleep 6; import -window root "$tmp/before.png" + "$KC" dark >/dev/null + sleep 3; import -window root "$tmp/after.png" + kill $k' 2>/dev/null +lum() { convert "$1" -crop 1x1+400+300 -colorspace Gray -format '%[fx:int(255*mean)]' info:; } +b=$(lum "$tmp/before.png"); a=$(lum "$tmp/after.png") +echo "KWrite window gray level: light $b, after the switch $a" +[ "$b" -gt 150 ] || fail "KWrite didn't start light" +[ "$a" -lt 100 ] || fail "KWrite didn't turn dark live" +echo "KWrite: ok" diff --git a/session/chandra-kde-colors b/session/chandra-kde-colors new file mode 100755 index 0000000..fd52e2e --- /dev/null +++ b/session/chandra-kde-colors @@ -0,0 +1,100 @@ +#!/bin/sh +# chandra-kde-colors dark|light +# +# Point KDE / Qt apps at a dark or light color scheme: called by the compositor when the Settings +# Dark mode switch flips (compositor/host/system_theme.mbt), in the login session only. +# +# KDE apps (KWrite, Kate, Dolphin, Okular...) don't read a scheme by its name: KColorScheme reads +# the [Colors:*] groups of ~/.config/kdeglobals, which Plasma's tools copy in from the scheme's +# .colors file. Setting only [General] ColorScheme=BreezeDark (what kwriteconfig did here before) +# leaves those groups as they were, or missing, and apps fall back to their built-in light +# colors. So this copies the scheme's color groups into kdeglobals itself, which needs neither +# Plasma, kded nor plasma-apply-colorscheme, then tells running apps (the KDE platform theme, +# QT_QPA_PLATFORMTHEME=kde) to repaint. +# +# The scheme: the dark/light counterpart of the current one when it has one (FooLight <-> +# FooDark), else BreezeDark/BreezeLight, else Chandra's own ChandraDark/ChandraLight +# (session/color-schemes, installed to /usr/local/share/color-schemes). +set -u +case "${1:-}" in + dark) from=light to=dark defaults="BreezeDark ChandraDark" ;; + light) from=dark to=light defaults="BreezeLight ChandraLight" ;; + *) echo "usage: chandra-kde-colors dark|light" >&2; exit 2 ;; +esac + +cfg="${XDG_CONFIG_HOME:-$HOME/.config}" +kg="$cfg/kdeglobals" +dirs="${XDG_DATA_HOME:-$HOME/.local/share}:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}" + +scheme_file() { # NAME -> path of NAME.colors in the data dirs, if any + old_ifs=$IFS; IFS=: + for d in $dirs; do + if [ -n "$d" ] && [ -f "$d/color-schemes/$1.colors" ]; then + IFS=$old_ifs; printf '%s\n' "$d/color-schemes/$1.colors"; return 0 + fi + done + IFS=$old_ifs; return 1 +} + +current="" +[ -f "$kg" ] && current=$(sed -n '/^\[General\]/,/^\[/s/^ColorScheme=//p' "$kg" | head -n 1) +name="" file="" +if [ -n "$current" ]; then + # Keep the case: MyLight -> MyDark, my-light -> my-dark, MYLIGHT -> MYDARK. + F=$(printf '%s' "$from" | sed 's/^./\U&/') T=$(printf '%s' "$to" | sed 's/^./\U&/') + UF=$(printf '%s' "$from" | tr a-z A-Z) UT=$(printf '%s' "$to" | tr a-z A-Z) + other=$(printf '%s' "$current" | sed "s/$F/$T/;t;s/$from/$to/;t;s/$UF/$UT/") + if [ "$other" != "$current" ] && file=$(scheme_file "$other"); then name=$other; fi +fi +if [ -z "$name" ]; then + for n in $defaults; do + if file=$(scheme_file "$n"); then name=$n; break; fi + done +fi +if [ -z "$name" ]; then + echo "chandra-kde-colors: no $to color scheme found in $dirs" >&2 + exit 1 +fi + +mkdir -p "$cfg" || exit 1 +[ -f "$kg" ] || : >"$kg" +# kdeglobals without its color groups (and with ColorScheme=NAME in [General]), then the +# scheme's color groups. +awk -v name="$name" -v kg="$kg" ' + function colors(g) { return g ~ /^\[(Colors:|ColorEffects:|WM\])/ } + FILENAME == kg { + if ($0 ~ /^\[/) { + group = $0 + if (group == "[General]") { general = 1 } + skip = colors(group) + } + if (skip) next + if (group == "[General]" && $0 ~ /^ColorScheme=/) next + print + if ($0 == "[General]") print "ColorScheme=" name + next + } + FNR == 1 { + if (!general) { print ""; print "[General]"; print "ColorScheme=" name } + print "" + } + /^\[/ { group = $0; keep = colors(group) } + keep { print } +' "$kg" "$file" >"$kg.chandra-new" && mv "$kg.chandra-new" "$kg" || exit 1 + +# Running apps: the KDE platform theme reloads its palette on KGlobalSettings.notifyChange +# (0 = PaletteChanged); KConfigWatcher users listen for kconfig ConfigChanged. +if command -v dbus-send >/dev/null 2>&1; then + dbus-send --session --type=signal /KGlobalSettings org.kde.KGlobalSettings.notifyChange \ + int32:0 int32:0 2>/dev/null +elif command -v gdbus >/dev/null 2>&1; then + gdbus emit --session --object-path /KGlobalSettings \ + --signal org.kde.KGlobalSettings.notifyChange 0 0 >/dev/null 2>&1 +fi +if command -v gdbus >/dev/null 2>&1; then + gdbus emit --session --object-path /kdeglobals --signal org.kde.kconfig.notify.ConfigChanged \ + "{'General': [b'ColorScheme'], 'Colors:Window': [b'BackgroundNormal'], 'Colors:View': [b'BackgroundNormal']}" \ + >/dev/null 2>&1 +fi +printf '%s\n' "$name" +true diff --git a/session/chandra-session b/session/chandra-session index e941068..d709c1a 100755 --- a/session/chandra-session +++ b/session/chandra-session @@ -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 diff --git a/session/color-schemes/ChandraDark.colors b/session/color-schemes/ChandraDark.colors new file mode 100644 index 0000000..2ac2664 --- /dev/null +++ b/session/color-schemes/ChandraDark.colors @@ -0,0 +1,125 @@ +# Chandra's own dark KDE color scheme, from the Moon Night desktop palette (config/themes). +# chandra-kde-colors uses it when Breeze's schemes aren't installed. + +[Colors:Window] +BackgroundAlternate=39,49,64 +BackgroundNormal=31,41,55 +DecorationFocus=124,156,255 +DecorationHover=124,156,255 +ForegroundActive=124,156,255 +ForegroundInactive=156,163,175 +ForegroundLink=124,156,255 +ForegroundNegative=248,113,113 +ForegroundNeutral=251,191,36 +ForegroundNormal=243,244,246 +ForegroundPositive=74,222,128 +ForegroundVisited=180,140,255 + +[Colors:View] +BackgroundAlternate=24,32,48 +BackgroundNormal=17,24,39 +DecorationFocus=124,156,255 +DecorationHover=124,156,255 +ForegroundActive=124,156,255 +ForegroundInactive=156,163,175 +ForegroundLink=124,156,255 +ForegroundNegative=248,113,113 +ForegroundNeutral=251,191,36 +ForegroundNormal=243,244,246 +ForegroundPositive=74,222,128 +ForegroundVisited=180,140,255 + +[Colors:Button] +BackgroundAlternate=59,70,88 +BackgroundNormal=55,65,81 +DecorationFocus=124,156,255 +DecorationHover=124,156,255 +ForegroundActive=124,156,255 +ForegroundInactive=156,163,175 +ForegroundLink=124,156,255 +ForegroundNegative=248,113,113 +ForegroundNeutral=251,191,36 +ForegroundNormal=243,244,246 +ForegroundPositive=74,222,128 +ForegroundVisited=180,140,255 + +[Colors:Selection] +BackgroundAlternate=98,124,210 +BackgroundNormal=124,156,255 +DecorationFocus=124,156,255 +DecorationHover=124,156,255 +ForegroundActive=11,16,32 +ForegroundInactive=156,163,175 +ForegroundLink=11,16,32 +ForegroundNegative=248,113,113 +ForegroundNeutral=251,191,36 +ForegroundNormal=11,16,32 +ForegroundPositive=74,222,128 +ForegroundVisited=180,140,255 + +[Colors:Tooltip] +BackgroundAlternate=31,41,55 +BackgroundNormal=17,24,39 +DecorationFocus=124,156,255 +DecorationHover=124,156,255 +ForegroundActive=124,156,255 +ForegroundInactive=156,163,175 +ForegroundLink=124,156,255 +ForegroundNegative=248,113,113 +ForegroundNeutral=251,191,36 +ForegroundNormal=243,244,246 +ForegroundPositive=74,222,128 +ForegroundVisited=180,140,255 + +[Colors:Complementary] +BackgroundAlternate=31,41,55 +BackgroundNormal=17,24,39 +DecorationFocus=124,156,255 +DecorationHover=124,156,255 +ForegroundActive=124,156,255 +ForegroundInactive=156,163,175 +ForegroundLink=124,156,255 +ForegroundNegative=248,113,113 +ForegroundNeutral=251,191,36 +ForegroundNormal=243,244,246 +ForegroundPositive=74,222,128 +ForegroundVisited=180,140,255 + +[Colors:Header] +BackgroundAlternate=39,49,64 +BackgroundNormal=31,41,55 +DecorationFocus=124,156,255 +DecorationHover=124,156,255 +ForegroundActive=124,156,255 +ForegroundInactive=156,163,175 +ForegroundLink=124,156,255 +ForegroundNegative=248,113,113 +ForegroundNeutral=251,191,36 +ForegroundNormal=243,244,246 +ForegroundPositive=74,222,128 +ForegroundVisited=180,140,255 + +[ColorEffects:Disabled] +Color=56,56,56 +ColorAmount=0 +ColorEffect=0 +ContrastAmount=0.65 +ContrastEffect=1 +IntensityAmount=0.1 +IntensityEffect=2 + +[ColorEffects:Inactive] +ChangeSelectionColor=true +Enable=false + +[General] +ColorScheme=ChandraDark +Name=Chandra Dark + +[WM] +activeBackground=31,41,55 +activeBlend=243,244,246 +activeForeground=243,244,246 +inactiveBackground=17,24,39 +inactiveBlend=156,163,175 +inactiveForeground=156,163,175 diff --git a/session/color-schemes/ChandraLight.colors b/session/color-schemes/ChandraLight.colors new file mode 100644 index 0000000..0ca5968 --- /dev/null +++ b/session/color-schemes/ChandraLight.colors @@ -0,0 +1,125 @@ +# Chandra's own light KDE color scheme, from the Moon Day desktop palette (config/themes). +# chandra-kde-colors uses it when Breeze's schemes aren't installed. + +[Colors:Window] +BackgroundAlternate=234,238,246 +BackgroundNormal=244,246,251 +DecorationFocus=59,107,255 +DecorationHover=59,107,255 +ForegroundActive=59,107,255 +ForegroundInactive=91,101,119 +ForegroundLink=59,107,255 +ForegroundNegative=220,38,38 +ForegroundNeutral=202,138,4 +ForegroundNormal=27,34,51 +ForegroundPositive=22,163,74 +ForegroundVisited=124,58,237 + +[Colors:View] +BackgroundAlternate=246,248,252 +BackgroundNormal=255,255,255 +DecorationFocus=59,107,255 +DecorationHover=59,107,255 +ForegroundActive=59,107,255 +ForegroundInactive=91,101,119 +ForegroundLink=59,107,255 +ForegroundNegative=220,38,38 +ForegroundNeutral=202,138,4 +ForegroundNormal=27,34,51 +ForegroundPositive=22,163,74 +ForegroundVisited=124,58,237 + +[Colors:Button] +BackgroundAlternate=210,218,232 +BackgroundNormal=221,227,240 +DecorationFocus=59,107,255 +DecorationHover=59,107,255 +ForegroundActive=59,107,255 +ForegroundInactive=91,101,119 +ForegroundLink=59,107,255 +ForegroundNegative=220,38,38 +ForegroundNeutral=202,138,4 +ForegroundNormal=27,34,51 +ForegroundPositive=22,163,74 +ForegroundVisited=124,58,237 + +[Colors:Selection] +BackgroundAlternate=120,150,255 +BackgroundNormal=59,107,255 +DecorationFocus=59,107,255 +DecorationHover=59,107,255 +ForegroundActive=255,255,255 +ForegroundInactive=91,101,119 +ForegroundLink=255,255,255 +ForegroundNegative=220,38,38 +ForegroundNeutral=202,138,4 +ForegroundNormal=255,255,255 +ForegroundPositive=22,163,74 +ForegroundVisited=124,58,237 + +[Colors:Tooltip] +BackgroundAlternate=244,246,251 +BackgroundNormal=251,252,255 +DecorationFocus=59,107,255 +DecorationHover=59,107,255 +ForegroundActive=59,107,255 +ForegroundInactive=91,101,119 +ForegroundLink=59,107,255 +ForegroundNegative=220,38,38 +ForegroundNeutral=202,138,4 +ForegroundNormal=27,34,51 +ForegroundPositive=22,163,74 +ForegroundVisited=124,58,237 + +[Colors:Complementary] +BackgroundAlternate=234,238,246 +BackgroundNormal=244,246,251 +DecorationFocus=59,107,255 +DecorationHover=59,107,255 +ForegroundActive=59,107,255 +ForegroundInactive=91,101,119 +ForegroundLink=59,107,255 +ForegroundNegative=220,38,38 +ForegroundNeutral=202,138,4 +ForegroundNormal=27,34,51 +ForegroundPositive=22,163,74 +ForegroundVisited=124,58,237 + +[Colors:Header] +BackgroundAlternate=234,238,246 +BackgroundNormal=244,246,251 +DecorationFocus=59,107,255 +DecorationHover=59,107,255 +ForegroundActive=59,107,255 +ForegroundInactive=91,101,119 +ForegroundLink=59,107,255 +ForegroundNegative=220,38,38 +ForegroundNeutral=202,138,4 +ForegroundNormal=27,34,51 +ForegroundPositive=22,163,74 +ForegroundVisited=124,58,237 + +[ColorEffects:Disabled] +Color=56,56,56 +ColorAmount=0 +ColorEffect=0 +ContrastAmount=0.65 +ContrastEffect=1 +IntensityAmount=0.1 +IntensityEffect=2 + +[ColorEffects:Inactive] +ChangeSelectionColor=true +Enable=false + +[General] +ColorScheme=ChandraLight +Name=Chandra Light + +[WM] +activeBackground=244,246,251 +activeBlend=27,34,51 +activeForeground=27,34,51 +inactiveBackground=234,238,246 +inactiveBlend=91,101,119 +inactiveForeground=91,101,119 diff --git a/session/install.py b/session/install.py index 4647d51..692b103 100755 --- a/session/install.py +++ b/session/install.py @@ -23,6 +23,10 @@ Installs: /usr/local/bin/chandra-root run one graphical app as root in the session (run0) /usr/local/bin/chandra-ctl talk to the running session: `chandra-ctl reload` loads the panel modules again (docs/reloading.md) + /usr/local/bin/chandra-kde-colors Dark mode for KDE/Qt apps: copies a color scheme into + kdeglobals (docs/dark-mode.md) + /usr/local/share/color-schemes/Chandra{Dark,Light}.colors KDE color schemes, used when Breeze's + aren't installed /usr/local/share/chandra/{config,wit,assets}/ files the compositor reads at runtime /usr/local/share/chandra/modules/*.wasm the panel's wasm modules (build them first: just modules) /usr/share/wayland-sessions/chandra.desktop display-manager entry @@ -48,6 +52,9 @@ targets = [ "/usr/local/bin/chandra-session", "/usr/local/bin/chandra-root", "/usr/local/bin/chandra-ctl", + "/usr/local/bin/chandra-kde-colors", + "/usr/local/share/color-schemes/ChandraDark.colors", + "/usr/local/share/color-schemes/ChandraLight.colors", "/usr/share/wayland-sessions/chandra.desktop", "/usr/share/xdg-desktop-portal/portals/chandra.portal", "/usr/share/xdg-desktop-portal/chandra-portals.conf", @@ -132,6 +139,9 @@ if not native: install(os.path.join(root, "session/chandra-session"), "/usr/local/bin/chandra-session") install(os.path.join(root, "session/chandra-root"), "/usr/local/bin/chandra-root") install(os.path.join(root, "session/chandra-ctl"), "/usr/local/bin/chandra-ctl") +install(os.path.join(root, "session/chandra-kde-colors"), "/usr/local/bin/chandra-kde-colors") +for f in ("ChandraDark.colors", "ChandraLight.colors"): + put(os.path.join(root, "session/color-schemes", f), "/usr/local/share/color-schemes/" + f, 0o644) # The display-manager entry stays a real file: some managers don't follow symlinks there. put(os.path.join(root, "session/chandra.desktop"), "/usr/share/wayland-sessions/chandra.desktop", 0o644) # xdg-desktop-portal reads backends only from /usr/share (or $XDG_DESKTOP_PORTAL_DIR), not