From b79ae7583329094946516afc21dd4015dd4637a0 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 16 Jul 2026 21:19:28 -0700 Subject: [PATCH] Fix graceful window closing before reboot --- bin/omarchy-hyprland-window-close-all | 2 +- .../shell.d/hyprland-window-close-all-test.sh | 33 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100755 test/shell.d/hyprland-window-close-all-test.sh diff --git a/bin/omarchy-hyprland-window-close-all b/bin/omarchy-hyprland-window-close-all index c88a640c..db0d9ae2 100755 --- a/bin/omarchy-hyprland-window-close-all +++ b/bin/omarchy-hyprland-window-close-all @@ -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 diff --git a/test/shell.d/hyprland-window-close-all-test.sh b/test/shell.d/hyprland-window-close-all-test.sh new file mode 100755 index 00000000..ec9251f6 --- /dev/null +++ b/test/shell.d/hyprland-window-close-all-test.sh @@ -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"