repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

feat(quickshell): make theme source explicit

71f2fc0d1e692d9f05da80da0ff3f7b9f2688d0a

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (5)

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

Modified
16 16 - verifies `quickshell/nugu/nugu.json` matches `hypr/generated/nugu.json` so the self-contained palette copy cannot silently drift;
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 -- verifies `FileView.watchChanges` by changing the temp mode file and waiting for `themeMode` to update without explicit `reloadTheme`;
19 +- verifies `themeSource` reports `auto` while following the mode file and `preview` during manual dark/light previews;
20 +- verifies dark/light previews are stable and not overwritten by mode-file watches until `auto` is selected again;
21 +- verifies `FileView.watchChanges` by changing the temp mode file and waiting for `themeMode` to update without explicit `reloadTheme` while source is `auto`;
20 22 - 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()`;
21 23 - optionally captures cropped scaffold screenshots when `NUGU_QS_SMOKE_SCREENSHOT_DIR` is set;
22 24 - crops only the focused monitor's top-left rollout region to avoid full-desktop screenshot leakage.
46 48 ```text
47 49 PASS nugu quickshell scaffold smoke
48 -initial={"theme":"dark","diagnostics":false,"bar":false,"nativeNotifications":false,"launcher":false,"clipboardPicker":false,"powerMenu":false,"pendingPower":"","lastOsd":"","lastPower":""}
49 -dark_open={"theme":"dark","diagnostics":true,"bar":true,"nativeNotifications":false,"launcher":false,"clipboardPicker":false,"powerMenu":false,"pendingPower":"","lastOsd":"","lastPower":""}
50 -light_open={"theme":"light","diagnostics":true,"bar":true,"nativeNotifications":false,"launcher":false,"clipboardPicker":false,"powerMenu":false,"pendingPower":"","lastOsd":"","lastPower":""}
50 +initial={"theme":"dark","themeSource":"auto","diagnostics":false,"bar":false,"nativeNotifications":false,"launcher":false,"clipboardPicker":false,"powerMenu":false,"pendingPower":"","lastOsd":"","lastPower":""}
51 +dark_open={"theme":"dark","themeSource":"preview","diagnostics":true,"bar":true,"nativeNotifications":false,"launcher":false,"clipboardPicker":false,"powerMenu":false,"pendingPower":"","lastOsd":"","lastPower":""}
52 +light_open={"theme":"light","themeSource":"preview","diagnostics":true,"bar":true,"nativeNotifications":false,"launcher":false,"clipboardPicker":false,"powerMenu":false,"pendingPower":"","lastOsd":"","lastPower":""}
51 53 auto_request=light
52 54 auto_light=light
55 +auto_light_source=auto
53 56 auto_watch_dark=dark
57 +auto_dark_source=auto
58 +preview_dark=dark
59 +preview_dark_source=preview
60 +preview_hold_dark=dark
54 61 preview_light=light
55 -after_reload=dark
56 -hidden={"theme":"dark","diagnostics":false,"bar":false,"nativeNotifications":false,"launcher":false,"clipboardPicker":false,"powerMenu":false,"pendingPower":"","lastOsd":"","lastPower":""}
62 +after_preview_reload=light
63 +auto_return=dark
64 +after_auto_return=dark
65 +hidden={"theme":"dark","themeSource":"auto","diagnostics":false,"bar":false,"nativeNotifications":false,"launcher":false,"clipboardPicker":false,"powerMenu":false,"pendingPower":"","lastOsd":"","lastPower":""}
57 66 smoke_exit=0
58 67 --- lingering qs ---
73 82 PASS nugu quickshell scaffold smoke
74 83 auto_request=light
75 84 auto_light=light
85 +auto_light_source=auto
76 86 auto_watch_dark=dark
87 +auto_dark_source=auto
88 +preview_dark=dark
89 +preview_dark_source=preview
90 +preview_hold_dark=dark
77 91 preview_light=light
78 -after_reload=dark
92 +after_preview_reload=light
93 +auto_return=dark
94 +after_auto_return=dark
79 95 screenshot_dark=/tmp/nugu-qs-theme-smoke/nugu-qs-dark.png
80 96 screenshot_light=/tmp/nugu-qs-theme-smoke/nugu-qs-light.png
81 97 smoke_exit=0
82 98 --- screenshots ---
83 --rw-r--r-- 1 oli oli 25209 Jun 17 06:05 nugu-qs-dark.png
84 --rw-r--r-- 1 oli oli 23692 Jun 17 06:05 nugu-qs-light.png
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
85 101 --- lingering qs ---

quickshell/nugu/README.md

Modified
47 47 qs ipc -c nugu call nugu hideAll
50 -`setThemeMode light|dark` previews a mode without writing global state.
51 -`setThemeMode auto` follows `~/.cache/nugu/mode` again. `scaffoldState` returns
52 -a compact JSON string for smoke tests. `hideAll` closes all Quickshell-owned
53 -surfaces and disables the opt-in native notification loader; it does not touch
54 -Ironbar, Mako, Hyprland, or user services.
50 +`setThemeMode light|dark` previews a mode without writing global state and
51 +without being overwritten by mode-file watches. `setThemeMode auto` follows
52 +`~/.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.
56 58 ## Phase 2A bar IPC

quickshell/nugu/Theme.qml

Modified
18 18 readonly property string palettePath: Qt.resolvedUrl("nugu.json")
20 20 property string mode: "dark"
21 + property bool followsModeFile: true
22 + readonly property string modeSource: followsModeFile ? "auto" : "preview"
21 23 property var palettes: ({ "dark": fallbackDark(), "light": fallbackDark() })
22 24 property var palette: fallbackDark()
47 49 // FileView updates text when loading finishes. Reading text immediately
48 50 // from fileChanged can see the old mode, so file changes only trigger a
49 - // reload; loaded applies the freshly-read mode.
51 + // reload. Loaded applies the freshly-read mode only while source is auto;
52 + // preview overrides must stay stable until IPC selects auto again.
50 53 onFileChanged: modeFile.reload()
51 - onLoaded: theme.applyMode(theme.readMode())
54 + onLoaded: {
55 + if (theme.followsModeFile) theme.applyMode(theme.readMode())
56 + }
54 59 Component.onCompleted: reload()
84 89 paletteFile.reload()
85 90 modeFile.reload()
86 91 palettes = readJson()
87 - applyMode(readMode())
93 + // Reload means reload palette data. Mode follows the file only in auto;
94 + // preview mode reloads colors but keeps the selected preview mode.
95 + applyMode(followsModeFile ? readMode() : mode)
90 98 function setMode(next: string): void {
91 99 // `auto` means follow Nugu's shared mode cache again. Dark/light are
92 - // preview overrides only; they never write global desktop state.
93 - if (next === "auto") reload()
94 - else applyMode(next)
100 + // stable preview overrides only; they never write global desktop state.
101 + if (next === "auto") {
102 + followsModeFile = true
103 + reload()
104 + } else {
105 + followsModeFile = false
106 + applyMode(next)
97 110 function fallbackDark() {

quickshell/nugu/shell.qml

Modified
40 40 return nuguTheme.mode
42 42 function themeMode(): string { return nuguTheme.mode }
43 + function themeSource(): string { return nuguTheme.modeSource }
44 45 // Scaffold smoke needs one cheap truth source and one cleanup button. This
45 46 // keeps test scripts brutal: show surfaces, assert state, hide everything.
46 47 function scaffoldState(): string {
47 48 return JSON.stringify({
48 49 "theme": nuguTheme.mode,
50 + "themeSource": nuguTheme.modeSource,
49 51 "diagnostics": root.diagnosticsVisible,
50 52 "bar": root.barVisible,
51 53 "nativeNotifications": root.nativeNotificationsEnabled,

quickshell/nugu/smoke.sh

Modified
65 65 fail "$label did not become $expected; last value: $value"
68 +hold_theme() {
69 + expected=$1
70 + label=$2
71 + value=
72 + i=0
73 + while [ "$i" -lt 8 ]; do
74 + value=$(ipc themeMode)
75 + case "$value" in
76 + *"$expected"*) ;;
77 + *) fail "$label changed away from $expected; value: $value" ;;
78 + esac
79 + i=$((i + 1))
80 + sleep 0.1
81 + done
82 + printf '%s' "$value"
68 85 capture_screenshot() {
69 86 label=$1
70 87 [ -n "$screenshot_dir" ] || return 0
96 113 sleep 4
98 115 state_initial=$(ipc scaffoldState)
116 +assert_contains "$state_initial" '"themeSource":"auto"' initial-state
99 117 assert_contains "$state_initial" '"diagnostics":false' initial-state
100 118 assert_contains "$state_initial" '"bar":false' initial-state
101 119 assert_contains "$state_initial" '"nativeNotifications":false' initial-state
106 124 state_dark_open=$(ipc scaffoldState)
107 125 assert_contains "$mode_dark" 'dark' theme-dark
108 126 assert_contains "$state_dark_open" '"theme":"dark"' dark-open-state
127 +assert_contains "$state_dark_open" '"themeSource":"preview"' dark-open-state
109 128 assert_contains "$state_dark_open" '"diagnostics":true' dark-open-state
110 129 assert_contains "$state_dark_open" '"bar":true' dark-open-state
111 130 assert_contains "$state_dark_open" '"nativeNotifications":false' dark-open-state
115 134 state_light_open=$(ipc scaffoldState)
116 135 assert_contains "$mode_light" 'light' theme-light
117 136 assert_contains "$state_light_open" '"theme":"light"' light-open-state
137 +assert_contains "$state_light_open" '"themeSource":"preview"' light-open-state
118 138 assert_contains "$state_light_open" '"diagnostics":true' light-open-state
119 139 assert_contains "$state_light_open" '"bar":true' light-open-state
120 140 assert_contains "$state_light_open" '"nativeNotifications":false' light-open-state
123 143 printf 'light' >"$home_tmp/.cache/nugu/mode"
124 144 mode_auto_request=$(ipc setThemeMode auto)
125 145 mode_auto_light=$(wait_theme light theme-auto-light)
146 +source_auto_light=$(ipc themeSource)
126 147 assert_contains "$mode_auto_light" 'light' theme-auto-light
148 +assert_contains "$source_auto_light" 'auto' theme-source-auto-light
128 150 printf 'dark' >"$home_tmp/.cache/nugu/mode"
129 151 mode_auto_watch_dark=$(wait_theme dark theme-auto-watch-dark)
152 +source_auto_dark=$(ipc themeSource)
130 153 assert_contains "$mode_auto_watch_dark" 'dark' theme-auto-watch-dark
154 +assert_contains "$source_auto_dark" 'auto' theme-source-auto-dark
156 +mode_preview_dark=$(ipc setThemeMode dark)
157 +source_preview_dark=$(ipc themeSource)
158 +assert_contains "$mode_preview_dark" 'dark' theme-preview-dark
159 +assert_contains "$source_preview_dark" 'preview' theme-source-preview-dark
160 +printf 'light' >"$home_tmp/.cache/nugu/mode"
161 +mode_preview_hold_dark=$(hold_theme dark theme-preview-hold-dark)
162 +assert_contains "$mode_preview_hold_dark" 'dark' theme-preview-hold-dark
132 164 mode_preview_light=$(ipc setThemeMode light)
133 165 assert_contains "$mode_preview_light" 'light' theme-preview-light
134 166 printf 'dark' >"$home_tmp/.cache/nugu/mode"
135 167 ipc reloadTheme >/dev/null
136 -mode_after_reload=$(wait_theme dark theme-reload)
137 -assert_contains "$mode_after_reload" 'dark' theme-reload
168 +mode_after_reload=$(hold_theme light theme-preview-reload-holds-light)
169 +assert_contains "$mode_after_reload" 'light' theme-preview-reload-holds-light
171 +mode_auto_return=$(ipc setThemeMode auto)
172 +mode_after_auto_return=$(wait_theme dark theme-auto-return-dark)
173 +assert_contains "$mode_after_auto_return" 'dark' theme-auto-return-dark
139 175 ipc hideAll >/dev/null
140 176 state_hidden=$(ipc scaffoldState)
177 +assert_contains "$state_hidden" '"themeSource":"auto"' hidden-state
178 +assert_contains "$state_hidden" '"theme":"dark"' hidden-state
141 179 assert_contains "$state_hidden" '"diagnostics":false' hidden-state
142 180 assert_contains "$state_hidden" '"bar":false' hidden-state
143 181 assert_contains "$state_hidden" '"launcher":false' hidden-state
158 196 printf 'light_open=%s\n' "$state_light_open"
159 197 printf 'auto_request=%s\n' "$mode_auto_request"
160 198 printf 'auto_light=%s\n' "$mode_auto_light"
199 +printf 'auto_light_source=%s\n' "$source_auto_light"
161 200 printf 'auto_watch_dark=%s\n' "$mode_auto_watch_dark"
201 +printf 'auto_dark_source=%s\n' "$source_auto_dark"
202 +printf 'preview_dark=%s\n' "$mode_preview_dark"
203 +printf 'preview_dark_source=%s\n' "$source_preview_dark"
204 +printf 'preview_hold_dark=%s\n' "$mode_preview_hold_dark"
162 205 printf 'preview_light=%s\n' "$mode_preview_light"
163 -printf 'after_reload=%s\n' "$mode_after_reload"
206 +printf 'after_preview_reload=%s\n' "$mode_after_reload"
207 +printf 'auto_return=%s\n' "$mode_auto_return"
208 +printf 'after_auto_return=%s\n' "$mode_after_auto_return"
164 209 printf 'hidden=%s\n' "$state_hidden"
165 210 if [ -n "$screenshot_dir" ]; then
166 211 printf 'screenshot_dark=%s\n' "$screenshot_dir/nugu-qs-dark.png"