Theme KDE/Qt apps (Dolphin, etc.) via kdeglobals
New theme/templates/kde/ renders the KDE color scheme embedded in kdeglobals
(Colors:View/Window/Button/Selection/Tooltip/Complementary + WM), themeing
every KDE/Qt app that reads it, not just Dolphin - kdeglobals was previously a
static, hand-maintained file (still bearing its ColorScheme=AetherRice name
from when the old aether app generated it once). The rendered output is
byte-identical to what was already there, confirming every mapped value was
right.
Needed render.py to grow a {key.rgb} placeholder format ("r,g,b" decimal, no
alpha - what kdeglobals uses, vs. the hex/rgba() formats every other template
needed). A couple of BackgroundAlternate shades don't correspond to any role
in colors.toml and are left as static literals rather than mapped to
something that wouldn't mean the same thing - noted in the template.
reload_apps() now also sends a best-effort dbus-send KGlobalSettings ping;
not every KDE app listens for it, so an already-open Dolphin may still need a
restart to fully pick up a change, same as most apps here.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Dujsk9jYfxUVLtb5B8eC94
This commit is contained in:
@@ -9,7 +9,8 @@
|
||||
|
||||
Templates live in theme/templates/<app>/{config.json,template}: config.json names the
|
||||
template file and the destination it gets rendered to (~ expanded). Placeholders in a
|
||||
template are {key}, {key.strip} (hex without '#'), or {key.rgba:ALPHA}.
|
||||
template are {key}, {key.strip} (hex without '#'), {key.rgb} ("r,g,b" decimal, no
|
||||
alpha - what KDE's kdeglobals/*.colors files use), or {key.rgba:ALPHA}.
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
@@ -50,6 +51,9 @@ def substitute(text, colors):
|
||||
if fmt == "rgba":
|
||||
r, g, b = hex_to_rgb(value)
|
||||
return f"rgba({r}, {g}, {b}, {arg})"
|
||||
if fmt == "rgb":
|
||||
r, g, b = hex_to_rgb(value)
|
||||
return f"{r},{g},{b}"
|
||||
sys.exit(f"render.py: unknown placeholder format '.{fmt}' in template")
|
||||
return PLACEHOLDER.sub(repl, text)
|
||||
|
||||
@@ -79,6 +83,11 @@ def reload_apps():
|
||||
for target in ("theme", "theme-widget"):
|
||||
subprocess.run(["quickshell", "-c", "default", "ipc", "call", target, "changed"],
|
||||
check=False, capture_output=True, timeout=3)
|
||||
# Best-effort: nudge already-running KDE/Qt apps (Dolphin, etc.) to re-read kdeglobals.
|
||||
# Not every app listens for this, so a restart is still the reliable way to see it.
|
||||
subprocess.run(["dbus-send", "--type=signal", "/KGlobalSettings",
|
||||
"org.kde.KGlobalSettings.notifyChange", "int32:0", "int32:0"],
|
||||
check=False, capture_output=True, timeout=3)
|
||||
|
||||
|
||||
def set_colors(pairs):
|
||||
|
||||
4
theme/templates/kde/config.json
Normal file
4
theme/templates/kde/config.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"template": "kdeglobals",
|
||||
"destination": "~/.config/kdeglobals"
|
||||
}
|
||||
106
theme/templates/kde/kdeglobals
Normal file
106
theme/templates/kde/kdeglobals
Normal file
@@ -0,0 +1,106 @@
|
||||
# Generated by theme/render.py from the active palette.
|
||||
# Edit the template at ~/.config/theme/templates/kde/kdeglobals, not the output.
|
||||
[KDE]
|
||||
ShowDeleteCommand=false
|
||||
|
||||
[PreviewSettings]
|
||||
EnableRemoteFolderThumbnail=false
|
||||
MaximumRemoteSize=0
|
||||
|
||||
[General]
|
||||
ColorScheme=AetherRice
|
||||
Name=AetherRice
|
||||
widgetStyle=Fusion
|
||||
|
||||
# BackgroundAlternate below is a shade with no equivalent role in theme/colors.toml
|
||||
# (a lighter tint in View/Button, a darker one in Window/Tooltip/Complementary) - left as a
|
||||
# static literal rather than mapped to something that wouldn't mean the same thing.
|
||||
[Colors:View]
|
||||
BackgroundNormal={background.rgb}
|
||||
BackgroundAlternate=32,33,44
|
||||
ForegroundNormal={foreground.rgb}
|
||||
ForegroundInactive={color8.rgb}
|
||||
ForegroundActive={foreground.rgb}
|
||||
ForegroundLink={color12.rgb}
|
||||
ForegroundVisited={color5.rgb}
|
||||
ForegroundNegative={color1.rgb}
|
||||
ForegroundNeutral={color3.rgb}
|
||||
ForegroundPositive={color2.rgb}
|
||||
DecorationFocus={accent.rgb}
|
||||
DecorationHover={color12.rgb}
|
||||
|
||||
[Colors:Window]
|
||||
BackgroundNormal={background.rgb}
|
||||
BackgroundAlternate=15,17,26
|
||||
ForegroundNormal={foreground.rgb}
|
||||
ForegroundInactive={color8.rgb}
|
||||
ForegroundActive={foreground.rgb}
|
||||
ForegroundLink={color12.rgb}
|
||||
ForegroundVisited={color5.rgb}
|
||||
ForegroundNegative={color1.rgb}
|
||||
ForegroundNeutral={color3.rgb}
|
||||
ForegroundPositive={color2.rgb}
|
||||
DecorationFocus={accent.rgb}
|
||||
DecorationHover={color12.rgb}
|
||||
|
||||
[Colors:Button]
|
||||
BackgroundNormal={background.rgb}
|
||||
BackgroundAlternate=32,33,44
|
||||
ForegroundNormal={foreground.rgb}
|
||||
ForegroundInactive={color8.rgb}
|
||||
ForegroundActive={foreground.rgb}
|
||||
ForegroundLink={color12.rgb}
|
||||
ForegroundVisited={color5.rgb}
|
||||
ForegroundNegative={color1.rgb}
|
||||
ForegroundNeutral={color3.rgb}
|
||||
ForegroundPositive={color2.rgb}
|
||||
DecorationFocus={accent.rgb}
|
||||
DecorationHover={color12.rgb}
|
||||
|
||||
[Colors:Selection]
|
||||
BackgroundNormal={accent.rgb}
|
||||
BackgroundAlternate={color12.rgb}
|
||||
ForegroundNormal=15,17,26
|
||||
ForegroundInactive=15,17,26
|
||||
ForegroundActive=15,17,26
|
||||
ForegroundLink=15,17,26
|
||||
ForegroundVisited=15,17,26
|
||||
ForegroundNegative={color1.rgb}
|
||||
ForegroundNeutral={color3.rgb}
|
||||
ForegroundPositive={color2.rgb}
|
||||
DecorationFocus={accent.rgb}
|
||||
DecorationHover={color12.rgb}
|
||||
|
||||
[Colors:Tooltip]
|
||||
BackgroundNormal=15,17,26
|
||||
BackgroundAlternate={background.rgb}
|
||||
ForegroundNormal={foreground.rgb}
|
||||
ForegroundInactive={color8.rgb}
|
||||
ForegroundActive={foreground.rgb}
|
||||
ForegroundLink={color12.rgb}
|
||||
ForegroundVisited={color5.rgb}
|
||||
ForegroundNegative={color1.rgb}
|
||||
ForegroundNeutral={color3.rgb}
|
||||
ForegroundPositive={color2.rgb}
|
||||
DecorationFocus={accent.rgb}
|
||||
DecorationHover={color12.rgb}
|
||||
|
||||
[Colors:Complementary]
|
||||
BackgroundNormal=15,17,26
|
||||
BackgroundAlternate={background.rgb}
|
||||
ForegroundNormal={foreground.rgb}
|
||||
ForegroundInactive={color8.rgb}
|
||||
ForegroundActive={foreground.rgb}
|
||||
ForegroundLink={color12.rgb}
|
||||
ForegroundVisited={color5.rgb}
|
||||
ForegroundNegative={color1.rgb}
|
||||
ForegroundNeutral={color3.rgb}
|
||||
ForegroundPositive={color2.rgb}
|
||||
DecorationFocus={accent.rgb}
|
||||
DecorationHover={color12.rgb}
|
||||
|
||||
[WM]
|
||||
activeBackground={background.rgb}
|
||||
activeForeground={foreground.rgb}
|
||||
inactiveBackground=15,17,26
|
||||
inactiveForeground={color8.rgb}
|
||||
Reference in New Issue
Block a user