#!/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