Fix graceful window closing before reboot

This commit is contained in:
David Heinemeier Hansson
2026-07-16 21:19:28 -07:00
parent 93181b6a22
commit b79ae75833
2 changed files with 34 additions and 1 deletions
+1 -1
View File
@@ -5,7 +5,7 @@
hyprctl clients -j | \
jq -r ".[].address" | \
while read -r addr; do
hyprctl dispatch "hl.dsp.window.close(\"address:$addr\")" >/dev/null 2>&1 || hyprctl dispatch closewindow "address:$addr"
hyprctl dispatch "hl.dsp.window.close({ window = \"address:$addr\" })" >/dev/null
done
# Move to first workspace
+33
View File
@@ -0,0 +1,33 @@
#!/bin/bash
source "$(dirname "$0")/base-test.sh"
test_tmp=$(mktemp -d)
trap 'rm -rf "$test_tmp"' EXIT
mock_bin="$test_tmp/bin"
hyprctl_log="$test_tmp/hyprctl.log"
mkdir -p "$mock_bin"
cat >"$mock_bin/hyprctl" <<'SH'
#!/bin/bash
if [[ $1 == "clients" ]]; then
printf '[{"address":"0xabc"},{"address":"0xdef"}]\n'
else
printf '%s\n' "$*" >>"$HYPRCTL_LOG"
fi
SH
chmod +x "$mock_bin/hyprctl"
PATH="$mock_bin:$PATH" HYPRCTL_LOG="$hyprctl_log" "$ROOT/bin/omarchy-hyprland-window-close-all"
expected_log="$test_tmp/expected.log"
cat >"$expected_log" <<'EOF'
dispatch hl.dsp.window.close({ window = "address:0xabc" })
dispatch hl.dsp.window.close({ window = "address:0xdef" })
dispatch hl.dsp.focus({ workspace = "1" })
EOF
diff -u "$expected_log" "$hyprctl_log" || fail "close-all targets each window with the Lua dispatcher"
pass "close-all targets each window with the Lua dispatcher"