forked from 1jehuang/jcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcapture_demo.sh
More file actions
executable file
·81 lines (64 loc) · 1.74 KB
/
capture_demo.sh
File metadata and controls
executable file
·81 lines (64 loc) · 1.74 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
# Full autonomous demo capture for jcode
# Captures screenshots of various UI states using niri + wtype
#
# Usage: ./capture_demo.sh [window_id]
# If window_id not provided, uses the focused window
set -e
SCRIPT_DIR="$(dirname "$0")"
OUTPUT_DIR="$SCRIPT_DIR/../docs/screenshots"
WINDOW_ID="${1:-}"
mkdir -p "$OUTPUT_DIR"
# Get window ID if not provided
if [ -z "$WINDOW_ID" ]; then
WINDOW_ID=$(niri msg focused-window 2>&1 | head -1 | grep -oP 'Window ID \K\d+')
echo "Using focused window: $WINDOW_ID"
fi
capture() {
local name="$1"
local keys="$2"
local delay="${3:-0.5}"
echo "📸 Capturing: $name"
# Focus the window
niri msg action focus-window --id "$WINDOW_ID"
sleep 0.2
# Inject keystrokes if provided
if [ -n "$keys" ]; then
echo " Typing: $keys"
wtype "$keys"
sleep "$delay"
fi
# Screenshot
niri msg action screenshot-window --path "$OUTPUT_DIR/${name}.png"
echo " ✅ Saved: $OUTPUT_DIR/${name}.png"
}
clear_input() {
# Clear any existing input with Ctrl+U, then Escape to close popups
wtype -M ctrl -k u
sleep 0.1
wtype -k Escape
sleep 0.2
}
echo "🎬 jcode Demo Capture"
echo " Window ID: $WINDOW_ID"
echo " Output: $OUTPUT_DIR"
echo ""
# Capture sequence
niri msg action focus-window --id "$WINDOW_ID"
sleep 0.3
# 1. Main UI (clean state)
clear_input
capture "main-ui" "" 0.3
# 2. Command palette (type /)
clear_input
capture "command-palette" "/" 0.3
# 3. Close palette, show help
wtype -k Escape
sleep 0.2
capture "help-view" "/help" 0.5
# Clean up - close any popups
wtype -k Escape
sleep 0.2
echo ""
echo "🎉 Done! Screenshots saved to $OUTPUT_DIR/"
ls -la "$OUTPUT_DIR/"*.png 2>/dev/null || echo "No screenshots found"