Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
jcode/scripts/replay_recording.sh at master · webtekdigitalai-tech/jcode · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
See all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
webtekdigitalai-tech
jcode
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
jcode
/
scripts
/
replay_recording.sh
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
executable file
·
178 lines (151 loc) · 4.61 KB
master
Breadcrumbs
jcode
/
scripts
/
replay_recording.sh
Copy path
Top
File metadata and controls
Code
Blame
executable file
·
178 lines (151 loc) · 4.61 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#!
/bin/bash
#
Replay a jcode recording as video
#
#
This script:
#
1. Starts a fresh jcode instance in a new terminal
#
2. Records the screen with wf-recorder
#
3. Replays the recorded keystrokes with proper timing
#
4. Outputs a video file
#
#
Usage: ./replay_recording.sh <recording.json> [output.mp4]
set
-e
RECORDING_FILE=
"
${1
:?
Usage
:
$0
<recording.json> [output.mp4]}
"
OUTPUT_FILE=
"
${2
:-
${RECORDING_FILE
%
.json}
.mp4}
"
SCRIPT_DIR=
"
$(
dirname
"
$0
"
)
"
if
[
!
-f
"
$RECORDING_FILE
"
]
;
then
echo
"
Error: Recording file not found:
$RECORDING_FILE
"
exit
1
fi
echo
"
🎬 jcode Recording Replay
"
echo
"
Input:
$RECORDING_FILE
"
echo
"
Output:
$OUTPUT_FILE
"
echo
"
"
#
Parse the recording and generate wtype commands
generate_wtype_script
() {
python3
<<
'
PYTHON
'
"
$RECORDING_FILE
"
import
json
import
sys
with
open
(sys.argv[
1
])
as
f:
events
=
json.load(f)
prev_time
=
0
for
event
in
events:
offset
=
event.get(
'
offset_ms
'
,
0
)
delay
=
offset
-
prev_time
prev_time
=
offset
if
delay
>
0
:
#
Sleep for the delay (in seconds)
print
(
f
"
sleep
{
delay
/
1000
:.3f
}
"
)
evt
=
event.get(
'
event
'
, {})
evt_type
=
evt.get(
'
type
'
)
if
evt_type
==
'
Key
'
:
data
=
evt.get(
'
data
'
, {})
code
=
data.get(
'
code
'
,
'
'
)
mods
=
data.get(
'
modifiers
'
, [])
#
Convert code to wtype format
key
=
None
if
code.startswith(
'
Char(
'
):
#
Extract character: Char('a') -> a
char
=
code[
6
:
-
2
]
if
len
(code)
>
7
else
code[
6
:
-
1
]
key
=
char
elif
code
==
'
Enter
'
:
key
=
'
Return
'
elif
code
==
'
Backspace
'
:
key
=
'
BackSpace
'
elif
code
==
'
Tab
'
:
key
=
'
Tab
'
elif
code
==
'
Esc
'
:
key
=
'
Escape
'
elif
code
==
'
Up
'
:
key
=
'
Up
'
elif
code
==
'
Down
'
:
key
=
'
Down
'
elif
code
==
'
Left
'
:
key
=
'
Left
'
elif
code
==
'
Right
'
:
key
=
'
Right
'
elif
code
==
'
Home
'
:
key
=
'
Home
'
elif
code
==
'
End
'
:
key
=
'
End
'
elif
code
==
'
PageUp
'
:
key
=
'
Page_Up
'
elif
code
==
'
PageDown
'
:
key
=
'
Page_Down
'
elif
code
==
'
Delete
'
:
key
=
'
Delete
'
elif
code
==
'
Insert
'
:
key
=
'
Insert
'
elif
code.startswith(
'
F
'
)
and
code[
1
:].isdigit():
key
=
code
#
F1, F2, etc.
else
:
#
Unknown key, skip
continue
if
key:
cmd
=
'
wtype
'
for
mod
in
mods:
if
mod
==
'
ctrl
'
:
cmd
+=
'
-M ctrl
'
elif
mod
==
'
alt
'
:
cmd
+=
'
-M alt
'
elif
mod
==
'
shift
'
:
cmd
+=
'
-M shift
'
if
len
(key)
==
1
and
key.isalnum():
cmd
+=
f
'
"
{
key
}
"
'
else
:
cmd
+=
f
'
-k
{
key
}
'
#
Release modifiers
for
mod
in
reversed
(mods):
if
mod
==
'
ctrl
'
:
cmd
+=
'
-m ctrl
'
elif
mod
==
'
alt
'
:
cmd
+=
'
-m alt
'
elif
mod
==
'
shift
'
:
cmd
+=
'
-m shift
'
print
(cmd)
PYTHON
}
#
Get the screen geometry for recording
GEOMETRY=
$(
niri msg focused-output
2>
/dev/null
|
grep -oP
'
Mode: \K\d+x\d+
'
|
head -1
||
echo
"
1920x1080
"
)
echo
"
📹 Starting screen recording...
"
echo
"
Geometry:
$GEOMETRY
"
echo
"
"
#
Start wf-recorder in background
wf-recorder -g
"
0,0
$GEOMETRY
"
-f
"
$OUTPUT_FILE
"
&
RECORDER_PID=
$!
sleep 1
#
Let recorder initialize
#
Start jcode in a new kitty window
echo
"
🚀 Starting jcode...
"
kitty --title
"
jcode-replay
"
-e bash -c
"
cd
$(
pwd
)
&& ~/.cargo/bin/jcode; read -p 'Press Enter to close...'
"
&
KITTY_PID=
$!
sleep 2
#
Wait for jcode to start
#
Focus the new window
sleep 0.5
#
Find and focus the jcode-replay window
WINDOW_ID=
$(
niri msg windows
2>
/dev/null
|
grep -B5
"
jcode-replay
"
|
grep -oP
'
Window ID \K\d+
'
|
head -1
)
if
[
-n
"
$WINDOW_ID
"
]
;
then
echo
"
Focusing window
$WINDOW_ID
"
niri msg action focus-window --id
"
$WINDOW_ID
"
sleep 0.3
fi
echo
"
⌨️ Replaying keystrokes...
"
echo
"
"
#
Generate and execute wtype script
generate_wtype_script
|
while
read
-r cmd
;
do
if
[[
"
$cmd
"
==
sleep
*
]]
;
then
eval
"
$cmd
"
else
eval
"
$cmd
"
2>
/dev/null
||
true
fi
done
echo
"
"
echo
"
⏹️ Stopping recording...
"
sleep 1
#
Final pause
#
Stop recorder
kill
$RECORDER_PID
2>
/dev/null
||
true
wait
$RECORDER_PID
2>
/dev/null
||
true
#
Clean up kitty window
kill
$KITTY_PID
2>
/dev/null
||
true
echo
"
"
echo
"
✅ Done!
"
echo
"
Video saved to:
$OUTPUT_FILE
"
ls -lh
"
$OUTPUT_FILE
"
You can’t perform that action at this time.