blob: 701f39765d01f0ed134ba598c8bd8a137753cd40 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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
|