repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

fix(quickshell): apply watched theme mode after load

60c459f89832a6fdae133a9733482fa4fd342c68

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (3)

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`;
20 +- 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()`;
19 21 - optionally captures cropped scaffold screenshots when `NUGU_QS_SMOKE_SCREENSHOT_DIR` is set;
20 22 - crops only the focused monitor's top-left rollout region to avoid full-desktop screenshot leakage.
46 48 initial={"theme":"dark","diagnostics":false,"bar":false,"nativeNotifications":false,"launcher":false,"clipboardPicker":false,"powerMenu":false,"pendingPower":"","lastOsd":"","lastPower":""}
47 49 dark_open={"theme":"dark","diagnostics":true,"bar":true,"nativeNotifications":false,"launcher":false,"clipboardPicker":false,"powerMenu":false,"pendingPower":"","lastOsd":"","lastPower":""}
48 50 light_open={"theme":"light","diagnostics":true,"bar":true,"nativeNotifications":false,"launcher":false,"clipboardPicker":false,"powerMenu":false,"pendingPower":"","lastOsd":"","lastPower":""}
51 +auto_request=light
49 52 auto_light=light
53 +auto_watch_dark=dark
54 +preview_light=light
50 55 after_reload=dark
51 56 hidden={"theme":"dark","diagnostics":false,"bar":false,"nativeNotifications":false,"launcher":false,"clipboardPicker":false,"powerMenu":false,"pendingPower":"","lastOsd":"","lastPower":""}
52 57 smoke_exit=0
67 72 ```text
68 73 PASS nugu quickshell scaffold smoke
74 +auto_request=light
75 +auto_light=light
76 +auto_watch_dark=dark
77 +preview_light=light
78 +after_reload=dark
69 79 screenshot_dark=/tmp/nugu-qs-theme-smoke/nugu-qs-dark.png
70 80 screenshot_light=/tmp/nugu-qs-theme-smoke/nugu-qs-light.png
71 81 smoke_exit=0
72 82 --- screenshots ---
73 --rw-r--r-- 1 oli oli 19695 Jun 17 05:58 nugu-qs-dark.png
74 --rw-r--r-- 1 oli oli 19037 Jun 17 05:58 nugu-qs-light.png
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
75 85 --- lingering qs ---

quickshell/nugu/Theme.qml

Modified
43 43 blockLoading: true
44 44 printErrors: false
45 45 watchChanges: true
46 - onFileChanged: theme.reload()
47 + // FileView updates text when loading finishes. Reading text immediately
48 + // from fileChanged can see the old mode, so file changes only trigger a
49 + // reload; loaded applies the freshly-read mode.
50 + onFileChanged: modeFile.reload()
51 + onLoaded: theme.applyMode(theme.readMode())
49 54 Component.onCompleted: reload()

quickshell/nugu/smoke.sh

Modified
29 29 fail() {
30 30 printf 'FAIL: %s\n' "$1" >&2
31 - printf '--- qs stdout ---\n' >&2
31 + printf '%s\n' '--- qs stdout ---' >&2
32 32 sed -n '1,120p' "$log_out" >&2 2>/dev/null || true
33 - printf '--- qs stderr ---\n' >&2
33 + printf '%s\n' '--- qs stderr ---' >&2
34 34 sed -n '1,120p' "$log_err" >&2 2>/dev/null || true
35 35 exit 1
52 +wait_theme() {
53 + expected=$1
54 + label=$2
55 + value=
56 + i=0
57 + while [ "$i" -lt 30 ]; do
58 + value=$(ipc themeMode)
59 + case "$value" in
60 + *"$expected"*) printf '%s' "$value"; return 0 ;;
61 + esac
62 + i=$((i + 1))
63 + sleep 0.1
64 + done
65 + fail "$label did not become $expected; last value: $value"
52 68 capture_screenshot() {
53 69 label=$1
54 70 [ -n "$screenshot_dir" ] || return 0
105 121 capture_screenshot light
107 123 printf 'light' >"$home_tmp/.cache/nugu/mode"
108 -mode_auto_light=$(ipc setThemeMode auto)
124 +mode_auto_request=$(ipc setThemeMode auto)
125 +mode_auto_light=$(wait_theme light theme-auto-light)
109 126 assert_contains "$mode_auto_light" 'light' theme-auto-light
128 +printf 'dark' >"$home_tmp/.cache/nugu/mode"
129 +mode_auto_watch_dark=$(wait_theme dark theme-auto-watch-dark)
130 +assert_contains "$mode_auto_watch_dark" 'dark' theme-auto-watch-dark
132 +mode_preview_light=$(ipc setThemeMode light)
133 +assert_contains "$mode_preview_light" 'light' theme-preview-light
111 134 printf 'dark' >"$home_tmp/.cache/nugu/mode"
112 135 ipc reloadTheme >/dev/null
113 -mode_after_reload=$(ipc themeMode)
136 +mode_after_reload=$(wait_theme dark theme-reload)
114 137 assert_contains "$mode_after_reload" 'dark' theme-reload
116 139 ipc hideAll >/dev/null
133 156 printf 'initial=%s\n' "$state_initial"
134 157 printf 'dark_open=%s\n' "$state_dark_open"
135 158 printf 'light_open=%s\n' "$state_light_open"
159 +printf 'auto_request=%s\n' "$mode_auto_request"
136 160 printf 'auto_light=%s\n' "$mode_auto_light"
161 +printf 'auto_watch_dark=%s\n' "$mode_auto_watch_dark"
162 +printf 'preview_light=%s\n' "$mode_preview_light"
137 163 printf 'after_reload=%s\n' "$mode_after_reload"
138 164 printf 'hidden=%s\n' "$state_hidden"
139 165 if [ -n "$screenshot_dir" ]; then