diff --git a/README.md b/README.md index 23b942c..03f3989 100644 --- a/README.md +++ b/README.md @@ -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//`](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//`](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 ` 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 diff --git a/kdeglobals b/kdeglobals index c458d67..2c681bc 100644 --- a/kdeglobals +++ b/kdeglobals @@ -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 diff --git a/theme/render.py b/theme/render.py index 716d278..7812f4e 100755 --- a/theme/render.py +++ b/theme/render.py @@ -9,7 +9,8 @@ Templates live in theme/templates//{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): diff --git a/theme/templates/kde/config.json b/theme/templates/kde/config.json new file mode 100644 index 0000000..7f20bec --- /dev/null +++ b/theme/templates/kde/config.json @@ -0,0 +1,4 @@ +{ + "template": "kdeglobals", + "destination": "~/.config/kdeglobals" +} diff --git a/theme/templates/kde/kdeglobals b/theme/templates/kde/kdeglobals new file mode 100644 index 0000000..38dfca6 --- /dev/null +++ b/theme/templates/kde/kdeglobals @@ -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}