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:
nico
2026-09-28 22:54:45 +02:00
parent 63a56f4a01
commit cc37bcfe18
5 changed files with 128 additions and 4 deletions

View File

@@ -29,7 +29,7 @@ bash /tmp/install.sh --deps # same, plus installs dependencies via pacman (Arc
| Notifications | [mako](mako/) — themed from the palette, same as the rest |
| Theming | [`theme/`](theme/) — homegrown palette-driven theme generator (`render.py`), controlled from the Quickshell desktop widget or the CLI |
| Qt/GTK theming | qt5ct, qt6ct, nwg-look |
| File manager | Dolphin (`kdeglobals`, `dolphinrc`) |
| File manager | Dolphin (`dolphinrc`; `kdeglobals`'s colors are generated, same theming pipeline as everything else — see Theming below) |
## The bar
@@ -69,8 +69,8 @@ The artwork is drawn procedurally in [`hypr/cursor/shapes.py`](hypr/cursor/shape
Theming used to go through a third-party app called aether; it's gone now (it didn't work reliably), replaced with a small homegrown system in [`theme/`](theme/):
- [`theme/colors.toml`](theme/colors.toml) is the single source of truth for the palette: accent, cursor, foreground/background, 16 ANSI colors, three extra `*_color` fields (`bar_color`, `pill_color`, `popup_color` — the terminal reuses `background`, already shared with mako), and four matching `*_opacity` floats (`bar_opacity`, `pill_opacity`, `popup_opacity`, `terminal_opacity`, each 0-1)
- [`theme/templates/<app>/`](theme/templates/) holds one `{config.json, template}` pair per themed app (Hyprland, Kitty, Rofi, mako). `config.json` names the destination file; the template uses `{key}` placeholders (`{color4}`, `{background}`, `{accent}`, …), `{key.strip}` for the hex without `#`, or `{key.rgba:ALPHA}` for a `rgba(r, g, b, ALPHA)` string
- [`theme/render.py`](theme/render.py) renders every template to its destination and reloads the affected apps (`hyprctl reload`, `makoctl reload`, kitty via `SIGUSR1`). It also pings the running shell over Quickshell's two IPC targets (`theme` for the bar, `theme-widget` for the widget itself — two separate top-level QML components) so the bar's own accent/border/pill colors and all four opacities, which live in QML rather than a config file another app reads, pick up changes immediately too — no restart. Run it after editing a template by hand, or use `--set KEY VALUE` to change one color (`#rrggbb`) or opacity (`0`-`1`) from a terminal, `--get KEY` / `--dump` to read the palette back out
- [`theme/templates/<app>/`](theme/templates/) holds one `{config.json, template}` pair per themed app (Hyprland, Kitty, Rofi, mako, and `kde` → `~/.config/kdeglobals`, which themes every KDE/Qt app that reads it — Dolphin, but also Kate, systemsettings, etc.). `config.json` names the destination file; the template uses `{key}` placeholders (`{color4}`, `{background}`, `{accent}`, …), `{key.strip}` for the hex without `#`, `{key.rgb}` for `r,g,b` decimal with no alpha (what kdeglobals uses), or `{key.rgba:ALPHA}` for a `rgba(r, g, b, ALPHA)` string. Adding a new themed app is just adding one more folder here — no code changes
- [`theme/render.py`](theme/render.py) renders every template to its destination and reloads the affected apps (`hyprctl reload`, `makoctl reload`, kitty via `SIGUSR1`, a best-effort `dbus-send` KGlobalSettings ping for KDE apps — not every KDE app actually listens for that, so an already-open Dolphin window may still need a restart to fully pick up a `kdeglobals` change, same as most apps here that aren't explicitly listed as reloading live). It also pings the running shell over Quickshell's two IPC targets (`theme` for the bar, `theme-widget` for the widget itself — two separate top-level QML components) so the bar's own accent/border/pill colors and all four opacities, which live in QML rather than a config file another app reads, pick up changes immediately too — no restart. Run it after editing a template by hand, or use `--set KEY VALUE` to change one color (`#rrggbb`) or opacity (`0`-`1`) from a terminal, `--get KEY` / `--dump` to read the palette back out
- [`theme/wallpaper.py`](theme/wallpaper.py) swaps the wallpaper: `apply <path>` archives the current one (deduped by hash) into `~/.local/share/quickshell/wallpapers/` and copies the new one to [`hypr/wallpaper.png`](hypr/wallpaper.png) (loaded via `swaybg` in `hyprland.lua`), `pick` does the same via a native file picker, `list` feeds the widget's gallery of past wallpapers
- [`theme/presets.py`](theme/presets.py) saves/loads/deletes named snapshots of the *entire* palette (every color and opacity value) as JSON files in `~/.local/share/quickshell/theme-presets/` — per-machine user data, not project config, so it's never tracked by this repo, same reasoning as the wallpaper history above. A built-in `Default` entry (the palette below) is always available, can't be saved over or deleted, and doesn't live in that folder — it's hardcoded in both `presets.py` and the widget

View File

@@ -1,3 +1,5 @@
# Generated by theme/render.py from the active palette.
# Edit the template at ~/.config/theme/templates/kde/kdeglobals, not the output.
[KDE]
ShowDeleteCommand=false
@@ -10,6 +12,9 @@ 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=26,27,38
BackgroundAlternate=32,33,44

View File

@@ -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):

View File

@@ -0,0 +1,4 @@
{
"template": "kdeglobals",
"destination": "~/.config/kdeglobals"
}

View 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}