1 +#
Nugu Hypr Theme Switching Implementation Plan 3 +> **For agentic workers:** REQUIRED SUB-SKILL: Use /skill:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
5 +**Goal:** Build a dark/light theme switch for Hyprland desktop apps with Nugu as palette source of truth and no switch-time dotfiles diffs.
7 +**Architecture:** Nugu generates deterministic dark/light fragments. A Hypr-linked switch script copies selected fragments into `${XDG_STATE_HOME:-~/.local/state}/nugu` and asks live apps to reload. Tracked app configs keep behavior/layout; runtime state contains only mode + color/style fragments.
9 +**Tech Stack:** Nushell generators/scripts, Hyprland Lua config, mako IPC, Ironbar GTK CSS hot reload, GSettings `org.gnome.desktop.interface color-scheme`, hyprtoolkit `source =` + inotify main-file poke.
13 +**Phase:** Single-plan implementation
15 +**Inventory:** `docs/super/inventory/2026-06-14-nugu-theme-current-state.md`
17 +**Contract:** `docs/super/specs/2026-06-14-nugu-theme-switch-contract.md`
21 +##
Research facts locked into this plan 23 +- `makoctl reload` reloads mako config without restart.
24 +- `ironbar` supports CSS hot reload; `ironbar --theme <path>`/`IRONBAR_CSS` select CSS path.
25 +- `ironbar style load-css <path>` loads additional hot-reloaded CSS; primary `--theme` is simpler for startup.
26 +- Hyprland can reload config with `hyprctl reload config-only`.
27 +- `hyprtoolkit 0.5.4` watches only main config path `~/.config/hypr/hyprtoolkit.conf` with `IN_MODIFY | IN_DONT_FOLLOW`.
28 +- `hyprtoolkit.conf` supports `source = <path>` but sourced files are not watched.
29 +- Therefore hyprtoolkit live switch requires: write sourced state file, then trigger `IN_MODIFY` on main config without changing content.
30 +- Runtime state path must be `$XDG_STATE_HOME/nugu` or `~/.local/state/nugu`, not cache.
34 +- Modify `nugu/hypr.nu`
35 + - Generate Hypr desktop runtime theme fragments for both modes from Nugu palette.
36 + - Keep `generated/nugu.lua` mode reader in sync with local-state path.
37 +- Modify `nugu/justfile`
38 + - Extend `hypr` recipe to copy generated runtime fragments into `hypr/generated/runtime/<mode>/`.
39 +- Create `hypr/scripts/nugu-theme.nu`
40 + - Runtime command: `dark | light | toggle | current | status | prepare`.
41 + - Writes local-state mode + theme files.
42 + - Reloads Hyprland, mako, Ironbar, GTK color-scheme, hyprtoolkit.
43 +- Modify `mako/config`
44 + - Include runtime state theme fragment, not tracked `mako/nugu.conf`.
45 +- Modify `ironbar/style.css`
46 + - Remove direct `@import url("nugu.css")`; base CSS becomes layout/style only.
47 +- Modify `ironbar/scripts/workspaces-watch.py`
48 + - Read Ironbar CSS vars from local-state runtime CSS instead of tracked `ironbar/nugu.css`.
49 +- Modify `wezterm/bugabinga/theme.lua`
50 + - Read Nugu mode from local-state path instead of cache.
51 +- Modify `hypr/systemd/ironbar.service`
52 + - Start Ironbar with runtime CSS path; prepare runtime CSS before start.
53 +- Modify `hypr/systemd/mako.service`
54 + - Prepare runtime mako fragment before start.
55 +- Modify `hypr/hyprtoolkit.conf`
56 + - Keep safe dark fallback values and static appearance variables.
57 + - Add `source = ~/.local/state/nugu/themes/hyprtoolkit.conf` at end.
58 +- Modify `hypr/modules/binds.lua` and `hypr/modules/hypr_osd.lua`
59 + - Add one manual toggle bind.
60 +- Regenerate `hypr/generated/nugu.lua`.
64 +##
Task 1: Update Nugu Hypr generator paths + runtime fragments 68 +- Modify: `nugu/hypr.nu`
69 +- Modify: `nugu/justfile`
70 +- Generated: `hypr/generated/nugu.lua`
71 +- Generated: `hypr/generated/runtime/dark/mako.conf`
72 +- Generated: `hypr/generated/runtime/light/mako.conf`
73 +- Generated: `hypr/generated/runtime/dark/ironbar-vars.css`
74 +- Generated: `hypr/generated/runtime/light/ironbar-vars.css`
75 +- Generated: `hypr/generated/runtime/dark/hyprtoolkit.conf`
76 +- Generated: `hypr/generated/runtime/light/hyprtoolkit.conf`
78 +- [ ] Replace generated Lua cache path in `nugu/hypr.nu` with local-state path:
81 +' local state_home = os.getenv("XDG_STATE_HOME") or (os.getenv("HOME") .. "/.local/state")'
82 +' local path = state_home .. "/nugu/mode"'
85 +- [ ] Add helpers to `nugu/hypr.nu`:
88 +def strip-hash [s: string] { $s | str replace "#" "" }
89 +def argb [color: string] { $"0xFF(strip-hash $color)" }
90 +def rgba [color: string, alpha: string] { $"($color)($alpha)" }
93 +- [ ] Add exported fragment generators to `nugu/hypr.nu`:
96 +export def mako [mode: string] {
97 + let p = (nugu $mode | get palette)
98 + $'# Generated by nugu/hypr.nu from Nugu palette.
99 +background-color=(rgba $p.ui.backdrop "ee")
100 +text-color=(rgba $p.ui.normal "ff")
101 +border-color=(rgba $p.ui.accent "ff")
102 +progress-color=over (rgba $p.ui.focus "ff")
105 +background-color=(rgba $p.content.backdrop "e6")
106 +text-color=(rgba $p.content.minor "ff")
107 +border-color=(rgba $p.ui.unfocus "ff")
108 +progress-color=over (rgba $p.content.minor "ff")
111 +border-color=(rgba $p.ui.accent "ff")
112 +progress-color=over (rgba $p.ui.focus "ff")
115 +background-color=(rgba $p.ui.backdrop "ff")
116 +text-color=(rgba $p.ui.important_global "ff")
117 +border-color=(rgba $p.error "ff")
118 +progress-color=over (rgba $p.error "ff")
120 +[summary~="[Ee]rror|[Ff]ailed|[Ff]ailure|[Cc]rash"]
121 +border-color=(rgba $p.error "ff")
122 +progress-color=over (rgba $p.error "ff")
124 +[summary~="[Ww]arn|[Ww]arning"]
125 +border-color=(rgba $p.warning "ff")
126 +progress-color=over (rgba $p.warning "ff")
128 +[summary~="[Ii]nfo|[Nn]otice"]
129 +border-color=(rgba $p.info "ff")
130 +progress-color=over (rgba $p.info "ff")
134 +export def ironbar-vars [mode: string] {
135 + let p = (nugu $mode | get palette)
136 + $'/* Generated by nugu/hypr.nu from Nugu palette. */
138 + --bg: ($p.ui.backdrop);
139 + --bg-transparent: ($p.ui.backdrop)ee;
140 + --surface: ($p.ui.minor);
141 + --fg: ($p.ui.normal);
142 + --accent: ($p.ui.accent);
143 + --focus: ($p.ui.focus);
144 + --important-global: ($p.ui.important_global);
145 + --on-focus: ($p.content.backdrop);
146 + --muted: ($p.ui.minor);
147 + --unfocus: ($p.ui.unfocus);
148 + --error: ($p.error);
149 + --warning: ($p.warning);
151 + --debug: ($p.debug);
152 + --border: ($p.ui.accent);
157 +export def hyprtoolkit [mode: string] {
158 + let p = (nugu $mode | get palette)
159 + $'# Generated by nugu/hypr.nu from Nugu palette.
160 +background = (argb $p.content.backdrop)
161 +base = (argb $p.ui.backdrop)
162 +alternate_base = (argb $p.ui.minor)
163 +text = (argb $p.content.normal)
164 +bright_text = (argb $p.ui.important_global)
165 +link_text = (argb $p.info)
166 +accent = (argb $p.ui.accent)
167 +accent_secondary = (argb $p.content.important_local)
172 +- [ ] Extend `nugu/justfile` `hypr` recipe to generate/copy `runtime/{dark,light}/{mako.conf,ironbar-vars.css,hyprtoolkit.conf}`.
177 +just --justfile nugu/justfile --working-directory nugu hypr
178 +just --justfile nugu/justfile --working-directory nugu check
181 +Expected: both exit `0`; runtime generated files exist.
185 +##
Task 2: Add local-state switch command 189 +- Create: `hypr/scripts/nugu-theme.nu`
191 +- [ ] Create script with this behavior:
196 +const valid_modes = [dark light]
199 + let base = ($env.XDG_STATE_HOME? | default ($env.HOME | path join ".local" "state"))
200 + $base | path join "nugu"
203 +def mode-path [] { state-root | path join "mode" }
204 +def themes-dir [] { state-root | path join "themes" }
205 +def generated-dir [] { $env.HOME | path join ".config" "hypr" "generated" "runtime" }
208 + let path = (mode-path)
209 + if ($path | path exists) {
210 + let mode = (open --raw $path | str trim)
211 + if $mode in $valid_modes { $mode } else { "dark" }
217 +def target-mode [mode: string] {
218 + if $mode == "toggle" {
219 + if (read-mode) == "dark" { "light" } else { "dark" }
220 + } else if $mode in $valid_modes {
222 + } else if $mode == "current" {
225 + error make { msg: "mode must be dark|light|toggle|current" }
229 +def write-text [path: path, text: string] {
230 + mkdir ($path | path dirname)
231 + $text | save --force --raw $path
234 +def copy-generated [mode: string, name: string] {
235 + let src = (generated-dir | path join $mode $name)
236 + if not ($src | path exists) { error make { msg: $"missing generated theme fragment: ($src)" } }
240 +def write-mode [mode: string] { write-text (mode-path) $"($mode)\n" }
241 +def write-mako [mode: string] { write-text (themes-dir | path join "mako.conf") (copy-generated $mode "mako.conf") }
242 +def write-hyprtoolkit [mode: string] { write-text (themes-dir | path join "hyprtoolkit.conf") (copy-generated $mode "hyprtoolkit.conf") }
244 +def ironbar-base-css-uri [] {
245 + let path = ($env.HOME | path join ".config" "ironbar" "style.css")
249 +def write-ironbar [mode: string] {
250 + let vars = (copy-generated $mode "ironbar-vars.css")
251 + let css = $'@import url("(ironbar-base-css-uri)");
253 + write-text (themes-dir | path join "ironbar.css") $css
256 +def set-gtk-mode [mode: string] {
257 + let scheme = if $mode == "dark" { "prefer-dark" } else { "prefer-light" }
258 + ^gsettings set org.gnome.desktop.interface color-scheme $scheme
261 +def reload-hypr [] { ^hyprctl reload config-only | ignore }
262 +def reload-mako [] { if (which makoctl | is-not-empty) { ^makoctl reload | ignore } }
263 +def reload-ironbar [] { if (which ironbar | is-not-empty) { ^ironbar reload | ignore } }
265 +def poke-hyprtoolkit [] {
266 + let path = ($env.HOME | path join ".config" "hypr" "hyprtoolkit.conf")
267 + if ($path | path exists) {
268 + let data = (open --raw $path)
269 + $data | save --force --raw $path
273 +def notify [mode: string] {
274 + if (which hyprctl | is-empty) { return }
275 + let color = if $mode == "dark" { "rgb(d86dd8)" } else { "rgb(922792)" }
276 + ^hyprctl notify 5 1200 $color $"nugu ($mode)" | ignore
279 +export def status [] { read-mode }
281 +export def prepare [mode = "current"] {
282 + let m = (target-mode $mode)
286 + write-hyprtoolkit $m
289 +export def main [mode = "toggle"] {
290 + let m = (target-mode $mode)
304 +chmod +x hypr/scripts/nugu-theme.nu
305 +nu-check --as-script hypr/scripts/nugu-theme.nu
306 +nu hypr/scripts/nugu-theme.nu prepare current
307 +nu hypr/scripts/nugu-theme.nu status
310 +Expected: script checks; state files exist; status prints `dark` or `light`.
314 +##
Task 3: Wire app configs to local-state fragments 318 +- Modify: `mako/config`
319 +- Modify: `ironbar/style.css`
320 +- Modify: `ironbar/scripts/workspaces-watch.py`
321 +- Modify: `wezterm/bugabinga/theme.lua`
322 +- Modify: `hypr/systemd/mako.service`
323 +- Modify: `hypr/systemd/ironbar.service`
324 +- Modify: `hypr/hyprtoolkit.conf`
326 +- [ ] In `mako/config`, replace:
329 +include=~/.config/mako/nugu.conf
335 +include=~/.local/state/nugu/themes/mako.conf
338 +- [ ] In `ironbar/style.css`, delete first line:
341 +@import url("nugu.css");
344 +- [ ] In `ironbar/scripts/workspaces-watch.py`, replace tracked CSS path with local state:
347 +state_home
= Path(os.environ.get(
"XDG_STATE_HOME", Path.home()
/ ".local" / "state"))
348 +path
= state_home
/ "nugu" / "themes" / "ironbar.css" 351 +- [ ] In `wezterm/bugabinga/theme.lua`, replace cache reader with local-state reader:
354 +local state_home = os.getenv 'XDG_STATE_HOME' or ( wez.home_dir .. '/.local/state' )
355 +local file = io.open( state_home .. '/nugu/mode', 'r' )
358 +- [ ] In `hypr/systemd/mako.service`, add before `ExecStart=`:
361 +ExecStartPre=/usr/bin/nu %h/.config/hypr/scripts/nugu-theme.nu prepare current
364 +- [ ] In `hypr/systemd/ironbar.service`, add before `ExecStart=`:
367 +ExecStartPre=/usr/bin/nu %h/.config/hypr/scripts/nugu-theme.nu prepare current
370 +and start with runtime CSS:
373 +ExecStart=/usr/bin/ironbar --theme %h/.local/state/nugu/themes/ironbar.css
376 +- [ ] In `hypr/hyprtoolkit.conf`, keep static settings and end with:
379 +# Runtime Nugu color override. Hyprtoolkit watches this file, not sourced files.
380 +source = ~/.local/state/nugu/themes/hyprtoolkit.conf
386 +nu hypr/scripts/nugu-theme.nu prepare current
389 +hyprctl reload config-only
392 +Expected: commands exit `0` when services/Hyprland are running.
396 +##
Task 4: Add Hyprland toggle bind + OSD 400 +- Modify: `hypr/modules/hypr_osd.lua`
401 +- Modify: `hypr/modules/binds.lua`
403 +- [ ] In `hypr/modules/hypr_osd.lua`, add before `M.notifications`:
407 + toggle = around("nu ~/.config/hypr/scripts/nugu-theme.nu toggle", notify(ok, 1200, t.ui.accent, "Nugu theme toggled")),
411 +- [ ] In `hypr/modules/binds.lua`, add after reload bind:
414 +bind(mod .. " + SHIFT + T", osd.theme.toggle, "toggle nugu light/dark")
420 +lua hypr/tests/commands_test.lua
421 +lua hypr/tests/hypr_osd_test.lua
422 +hyprctl reload config-only
423 +hyprctl configerrors
426 +Expected: tests pass; no new config error.
430 +##
Task 5: Final verification 432 +- [ ] Run generator validation:
435 +just --justfile nugu/justfile --working-directory nugu check
436 +just --justfile nugu/justfile --working-directory nugu hypr
439 +- [ ] Run diff invariant:
442 +before
=$(git status --short --ignore-submodules=dirty) 443 +nu hypr/scripts/nugu-theme.nu light
444 +nu hypr/scripts/nugu-theme.nu dark
445 +after
=$(git status --short --ignore-submodules=dirty) 446 +test
"$before" =
"$after" 449 +- [ ] Verify GTK preference:
452 +nu hypr/scripts/nugu-theme.nu light
453 +gsettings get org.gnome.desktop.interface color-scheme
454 +nu hypr/scripts/nugu-theme.nu dark
455 +gsettings get org.gnome.desktop.interface color-scheme
465 +- [ ] Ask user for visual confirmation:
468 +nu ~/.config/hypr/scripts/nugu-theme.nu light
469 +nu ~/.config/hypr/scripts/nugu-theme.nu dark
472 +Expected visual result:
474 +- Hypr borders switch.
475 +- Mako notifications switch after `makoctl reload`.
476 +- Ironbar switches without restart.
477 +- GTK/Qt apps that honor color-scheme switch or pick new preference on repaint.
478 +- Hyprtoolkit apps already open update color where their widgets use palette color callbacks; static font/rounding changes remain next-launch.