diff options
Diffstat (limited to 'tests/layout-navigate/fake-hyprctl')
| -rwxr-xr-x | tests/layout-navigate/fake-hyprctl | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/layout-navigate/fake-hyprctl b/tests/layout-navigate/fake-hyprctl new file mode 100755 index 0000000..701f397 --- /dev/null +++ b/tests/layout-navigate/fake-hyprctl @@ -0,0 +1,48 @@ +#!/bin/sh +# Fake hyprctl for testing layout-navigate. +# +# State files live in $FAKE_HYPR_DIR: +# activewindow.json - first activewindow call returns this +# activewindow.1.json - second call (after togglespecialworkspace) returns this, if present +# layout.json - getoption general:layout returns this +# dispatch.log - every "dispatch" invocation appended here (one line) +# call-count - internal counter for activewindow calls + +: "${FAKE_HYPR_DIR:?FAKE_HYPR_DIR must be set}" + +cmd="$1" +shift + +case "$cmd" in + activewindow) + # Count calls so tests can provide a post-toggle state + count_file="$FAKE_HYPR_DIR/call-count" + count=$(cat "$count_file" 2>/dev/null || echo 0) + next=$((count + 1)) + echo "$next" > "$count_file" + + if [ "$count" -eq 0 ]; then + cat "$FAKE_HYPR_DIR/activewindow.json" + else + # Try numbered file; fall back to original + numbered="$FAKE_HYPR_DIR/activewindow.$count.json" + if [ -f "$numbered" ]; then + cat "$numbered" + else + cat "$FAKE_HYPR_DIR/activewindow.json" + fi + fi + ;; + getoption) + cat "$FAKE_HYPR_DIR/layout.json" + ;; + dispatch) + # Log the entire dispatch invocation as one line + echo "dispatch $*" >> "$FAKE_HYPR_DIR/dispatch.log" + echo "ok" + ;; + *) + echo "fake-hyprctl: unknown command '$cmd'" >&2 + exit 1 + ;; +esac |
