repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

test(quickshell): assert loaded nugu tokens

5184dfa76bdfc3cd26c558711c05b30d53b23b1a

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (4)

docs/super/inventory/2026-06-17-quickshell-theme-screenshot-smoke.md

Modified
17 17 - explicitly renders the scaffold in dark mode and light mode;
18 18 - still verifies `setThemeMode auto` from the temp Nugu mode cache;
19 19 - verifies `themeSource` reports `auto` while following the mode file and `preview` during manual dark/light previews;
20 +- verifies `themeState` exposes actual loaded Nugu token values and compares them against `quickshell/nugu/nugu.json` in dark, light, preview, and auto states;
20 21 - verifies dark/light previews are stable and not overwritten by mode-file watches until `auto` is selected again;
21 22 - verifies `FileView.watchChanges` by changing the temp mode file and waiting for `themeMode` to update without explicit `reloadTheme` while source is `auto`;
22 23 - applies watched mode changes from `FileView.onLoaded`, not directly from `onFileChanged`, because a minimal probe showed `text()` can still contain the old file content inside `onFileChanged` immediately after `reload()`;
67 68 --- lingering qs ---
71 +The same run printed `dark_theme_state`, `light_theme_state`, `auto_light_theme_state`, `auto_dark_theme_state`, and `auto_return_theme_state`; the smoke runner compared each exposed token against the self-contained `quickshell/nugu/nugu.json` before reporting PASS.
70 73 Screenshot gate:
72 75 ```sh
96 99 screenshot_light=/tmp/nugu-qs-theme-smoke/nugu-qs-light.png
97 100 smoke_exit=0
98 101 --- screenshots ---
99 --rw-r--r-- 1 oli oli 26573 Jun 17 06:11 nugu-qs-dark.png
100 --rw-r--r-- 1 oli oli 25030 Jun 17 06:11 nugu-qs-light.png
102 +-rw-r--r-- 1 oli oli 24828 Jun 17 06:18 nugu-qs-dark.png
103 +-rw-r--r-- 1 oli oli 23693 Jun 17 06:18 nugu-qs-light.png
101 104 --- lingering qs ---

quickshell/nugu/README.md

Modified
43 43 qs ipc -c nugu call nugu setThemeMode light
44 44 qs ipc -c nugu call nugu setThemeMode dark
45 45 qs ipc -c nugu call nugu setThemeMode auto
46 +qs ipc -c nugu call nugu themeSource
47 +qs ipc -c nugu call nugu themeState
46 48 qs ipc -c nugu call nugu scaffoldState
47 49 qs ipc -c nugu call nugu hideAll
50 52 `setThemeMode light|dark` previews a mode without writing global state and
51 53 without being overwritten by mode-file watches. `setThemeMode auto` follows
52 54 `~/.cache/nugu/mode` again. `themeSource` returns `preview` or `auto`.
53 -`scaffoldState` returns a compact JSON string for smoke tests, including the same
54 -source marker. `hideAll` closes all Quickshell-owned surfaces and disables the
55 -opt-in native notification loader; it does not touch Ironbar, Mako, Hyprland, or
56 -user services.
55 +`themeState` returns the current mode/source plus key Nugu tokens so smoke tests
56 +can prove real palette values, not just mode names. `scaffoldState` returns a
57 +compact JSON string for surface smoke tests, including the same source marker.
58 +`hideAll` closes all Quickshell-owned surfaces and disables the opt-in native
59 +notification loader; it does not touch Ironbar, Mako, Hyprland, or user services.
58 61 ## Phase 2A bar IPC

quickshell/nugu/shell.qml

Modified
42 42 function themeMode(): string { return nuguTheme.mode }
43 43 function themeSource(): string { return nuguTheme.modeSource }
44 + function themeState(): string {
45 + // Smoke tests assert actual token values, not only mode names. Keep
46 + // this flat so shell tests can parse it without depending on jq.
47 + return JSON.stringify({
48 + "mode": nuguTheme.mode,
49 + "source": nuguTheme.modeSource,
50 + "error": nuguTheme.error,
51 + "warning": nuguTheme.warning,
52 + "info": nuguTheme.info,
53 + "debug": nuguTheme.debug,
54 + "contentNormal": nuguTheme.content.normal,
55 + "contentBackdrop": nuguTheme.content.backdrop,
56 + "contentAccent": nuguTheme.content.accent,
57 + "uiNormal": nuguTheme.ui.normal,
58 + "uiBackdrop": nuguTheme.ui.backdrop,
59 + "uiAccent": nuguTheme.ui.accent,
60 + "uiFocus": nuguTheme.ui.focus
61 + })
62 + }
45 64 // Scaffold smoke needs one cheap truth source and one cleanup button. This
46 65 // keeps test scripts brutal: show surfaces, assert state, hide everything.

quickshell/nugu/smoke.sh

Modified
52 +assert_theme_state() {
53 + mode=$1
54 + source=$2
55 + state=$3
56 + label=$4
58 + python - "$config_dir/nugu.json" "$mode" "$source" "$state" "$label" <<'PY'
59 +import json, sys
60 +palette_path, mode, source, state_text, label = sys.argv[1:]
61 +state = json.loads(state_text)
62 +palette = json.load(open(palette_path))[mode]
63 +expected = {
64 + "mode": mode,
65 + "source": source,
66 + "error": palette["error"],
67 + "warning": palette["warning"],
68 + "info": palette["info"],
69 + "debug": palette["debug"],
70 + "contentNormal": palette["content"]["normal"],
71 + "contentBackdrop": palette["content"]["backdrop"],
72 + "contentAccent": palette["content"]["accent"],
73 + "uiNormal": palette["ui"]["normal"],
74 + "uiBackdrop": palette["ui"]["backdrop"],
75 + "uiAccent": palette["ui"]["accent"],
76 + "uiFocus": palette["ui"]["focus"],
78 +for key, value in expected.items():
79 + if state.get(key) != value:
80 + raise SystemExit(f"{label}: {key} expected {value!r}, got {state.get(key)!r} in {state_text}")
81 +PY
52 84 wait_theme() {
53 85 expected=$1
54 86 label=$2
122 154 ipc showBar >/dev/null
123 155 mode_dark=$(ipc setThemeMode dark)
124 156 state_dark_open=$(ipc scaffoldState)
157 +theme_dark_state=$(ipc themeState)
125 158 assert_contains "$mode_dark" 'dark' theme-dark
126 159 assert_contains "$state_dark_open" '"theme":"dark"' dark-open-state
127 160 assert_contains "$state_dark_open" '"themeSource":"preview"' dark-open-state
128 161 assert_contains "$state_dark_open" '"diagnostics":true' dark-open-state
129 162 assert_contains "$state_dark_open" '"bar":true' dark-open-state
130 163 assert_contains "$state_dark_open" '"nativeNotifications":false' dark-open-state
164 +assert_theme_state dark preview "$theme_dark_state" dark-theme-state
131 165 capture_screenshot dark
133 167 mode_light=$(ipc setThemeMode light)
134 168 state_light_open=$(ipc scaffoldState)
169 +theme_light_state=$(ipc themeState)
135 170 assert_contains "$mode_light" 'light' theme-light
136 171 assert_contains "$state_light_open" '"theme":"light"' light-open-state
137 172 assert_contains "$state_light_open" '"themeSource":"preview"' light-open-state
138 173 assert_contains "$state_light_open" '"diagnostics":true' light-open-state
139 174 assert_contains "$state_light_open" '"bar":true' light-open-state
140 175 assert_contains "$state_light_open" '"nativeNotifications":false' light-open-state
176 +assert_theme_state light preview "$theme_light_state" light-theme-state
141 177 capture_screenshot light
143 179 printf 'light' >"$home_tmp/.cache/nugu/mode"
144 180 mode_auto_request=$(ipc setThemeMode auto)
145 181 mode_auto_light=$(wait_theme light theme-auto-light)
146 182 source_auto_light=$(ipc themeSource)
183 +theme_auto_light_state=$(ipc themeState)
147 184 assert_contains "$mode_auto_light" 'light' theme-auto-light
148 185 assert_contains "$source_auto_light" 'auto' theme-source-auto-light
186 +assert_theme_state light auto "$theme_auto_light_state" auto-light-theme-state
150 188 printf 'dark' >"$home_tmp/.cache/nugu/mode"
151 189 mode_auto_watch_dark=$(wait_theme dark theme-auto-watch-dark)
152 190 source_auto_dark=$(ipc themeSource)
191 +theme_auto_dark_state=$(ipc themeState)
153 192 assert_contains "$mode_auto_watch_dark" 'dark' theme-auto-watch-dark
154 193 assert_contains "$source_auto_dark" 'auto' theme-source-auto-dark
194 +assert_theme_state dark auto "$theme_auto_dark_state" auto-dark-theme-state
156 196 mode_preview_dark=$(ipc setThemeMode dark)
157 197 source_preview_dark=$(ipc themeSource)
171 211 mode_auto_return=$(ipc setThemeMode auto)
172 212 mode_after_auto_return=$(wait_theme dark theme-auto-return-dark)
213 +theme_auto_return_state=$(ipc themeState)
173 214 assert_contains "$mode_after_auto_return" 'dark' theme-auto-return-dark
215 +assert_theme_state dark auto "$theme_auto_return_state" auto-return-theme-state
175 217 ipc hideAll >/dev/null
176 218 state_hidden=$(ipc scaffoldState)
193 235 printf 'PASS nugu quickshell scaffold smoke\n'
194 236 printf 'initial=%s\n' "$state_initial"
195 237 printf 'dark_open=%s\n' "$state_dark_open"
238 +printf 'dark_theme_state=%s\n' "$theme_dark_state"
196 239 printf 'light_open=%s\n' "$state_light_open"
240 +printf 'light_theme_state=%s\n' "$theme_light_state"
197 241 printf 'auto_request=%s\n' "$mode_auto_request"
198 242 printf 'auto_light=%s\n' "$mode_auto_light"
199 243 printf 'auto_light_source=%s\n' "$source_auto_light"
244 +printf 'auto_light_theme_state=%s\n' "$theme_auto_light_state"
200 245 printf 'auto_watch_dark=%s\n' "$mode_auto_watch_dark"
201 246 printf 'auto_dark_source=%s\n' "$source_auto_dark"
247 +printf 'auto_dark_theme_state=%s\n' "$theme_auto_dark_state"
202 248 printf 'preview_dark=%s\n' "$mode_preview_dark"
203 249 printf 'preview_dark_source=%s\n' "$source_preview_dark"
204 250 printf 'preview_hold_dark=%s\n' "$mode_preview_hold_dark"
206 252 printf 'after_preview_reload=%s\n' "$mode_after_reload"
207 253 printf 'auto_return=%s\n' "$mode_auto_return"
208 254 printf 'after_auto_return=%s\n' "$mode_after_auto_return"
255 +printf 'auto_return_theme_state=%s\n' "$theme_auto_return_state"
209 256 printf 'hidden=%s\n' "$state_hidden"
210 257 if [ -n "$screenshot_dir" ]; then
211 258 printf 'screenshot_dark=%s\n' "$screenshot_dir/nugu-qs-dark.png"