-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTaskfile.yml
More file actions
384 lines (344 loc) · 11.5 KB
/
Copy pathTaskfile.yml
File metadata and controls
384 lines (344 loc) · 11.5 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
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
version: "3"
vars:
NAME:
sh: grep 'name =' Cargo.toml | head -n 1 | cut -d'"' -f2
VERSION:
sh: grep '^version =' Cargo.toml | head -n 1 | cut -d'"' -f2
ARCH:
sh: uname -m
WIDTH: "1280"
HEIGHT: "720"
IMAGE_NAME: "{{.NAME}}-builder"
IMAGE_TAG:
sh: sha256sum Dockerfile | cut -d' ' -f1
# Auto-detect the first X11 display owned by a running gamecomp instance.
# Scans /tmp/.X11-unix/X* and checks for GAMESCOPE_PID on the root window.
GAMECOMP_DISPLAY:
sh: |
for sock in /tmp/.X11-unix/X*; do
num="${sock##*/tmp/.X11-unix/X}"
if DISPLAY=":${num}" xprop -root GAMESCOPE_PID 2>/dev/null | grep -q '= '; then
echo ":${num}"
exit 0
fi
done
echo ""
tasks:
default:
aliases:
- help
cmds:
- go-task --list
build:
desc: Build release binary
cmds:
- cargo build --release
build:debug:
desc: Build debug binary
cmds:
- cargo build
check:
desc: Run cargo check (fast compile validation)
cmds:
- cargo check --all-features
test:
desc: Run all tests
cmds:
- cargo test
lint:
desc: Run clippy with all features (zero warnings)
cmds:
- cargo clippy --all-features -- -D warnings
fmt:
desc: Format all code
cmds:
- cargo fmt
fmt:check:
desc: Check formatting without modifying files
cmds:
- cargo fmt -- --check
ci:
desc: Run full CI pipeline (fmt check, clippy, tests)
cmds:
- task: fmt:check
- task: lint
- task: test
run:
desc: "Build and run (APP=program)"
requires:
vars: [APP]
cmds:
- cargo run -- --xwayland-count 2 -W {{.WIDTH}} -H {{.HEIGHT}} -- {{.APP}} {{.CLI_ARGS}}
run:headless:
desc: "Build and run in headless mode (APP=program)"
requires:
vars: [APP]
cmds:
- cargo run -- --xwayland-count 2 --backend headless -W {{.WIDTH}} -H {{.HEIGHT}} -- {{.APP}} {{.CLI_ARGS}}
run:release:
desc: "Build and run release binary (APP=program)"
requires:
vars: [APP]
cmds:
- cargo run -- --xwayland-count 2 release -W {{.WIDTH}} -H {{.HEIGHT}} -- {{.APP}} {{.CLI_ARGS}}
install:
desc: Build release binary and install to /usr/bin
cmds:
- task: build
- sudo cp ./target/release/{{.NAME}} /usr/bin/
clean:
desc: Remove build artifacts
cmds:
- cargo clean
doc:
desc: Build and open documentation
cmds:
- cargo doc --open --no-deps
# ─── XWayland debug commands ────────────────────────────────────────
# These use xprop/xdotool to inspect and control gamecomp's XWayland
# servers at runtime. Set DISPLAY to the target server (e.g., :1).
x11:servers:
desc: "List running gamecomp XWayland servers and their properties"
cmds:
- |
echo "=== Gamecomp XWayland Servers ==="
found=0
for sock in /tmp/.X11-unix/X*; do
num="${sock##*/tmp/.X11-unix/X}"
sid=$(DISPLAY=":${num}" xprop -root GAMESCOPE_XWAYLAND_SERVER_ID 2>/dev/null | grep -oP '= \K\d+') || true
if [ -n "$sid" ]; then
pid=$(DISPLAY=":${num}" xprop -root GAMESCOPE_PID 2>/dev/null | grep -oP '= \K\d+') || true
printf " :%-4s server_id=%-4s compositor_pid=%s\n" "$num" "$sid" "${pid:-?}"
found=1
fi
done
if [ "$found" -eq 0 ]; then
echo " (no gamecomp servers running)"
fi
x11:focus:
desc: "Show current focus state (X11_DISPLAY=:N)"
vars:
X_DISPLAY: '{{.X11_DISPLAY | default .GAMECOMP_DISPLAY}}'
cmds:
- |
echo "=== Focus State on {{.X_DISPLAY}} ==="
DISPLAY={{.X_DISPLAY}} xprop -root \
GAMESCOPE_FOCUSED_APP \
GAMESCOPE_FOCUSED_WINDOW \
GAMESCOPE_FOCUSABLE_APPS \
GAMESCOPE_FOCUSABLE_WINDOWS \
GAMESCOPE_FOCUS_DISPLAY \
2>/dev/null || echo "(no gamecomp server on {{.X_DISPLAY}})"
x11:windows:
desc: "List all X11 windows on a display (X11_DISPLAY=:N)"
vars:
X_DISPLAY: '{{.X11_DISPLAY | default .GAMECOMP_DISPLAY}}'
cmds:
- |
echo "=== X11 Windows on {{.X_DISPLAY}} ==="
DISPLAY={{.X_DISPLAY}} xwininfo -root -children 2>/dev/null || echo "(xwininfo not available or no server on {{.X_DISPLAY}})"
x11:focus-app:
desc: "Focus a Steam AppID (X11_DISPLAY=:N APP_ID=NNN)"
requires:
vars: [APP_ID]
vars:
X_DISPLAY: '{{.X11_DISPLAY | default .GAMECOMP_DISPLAY}}'
cmds:
- |
echo "Requesting focus on AppID {{.APP_ID}} via {{.X_DISPLAY}}"
DISPLAY={{.X_DISPLAY}} xprop -root -format GAMESCOPECTRL_BASELAYER_APPID 32c \
-set GAMESCOPECTRL_BASELAYER_APPID {{.APP_ID}}
x11:focus-window:
desc: "Focus a specific window ID (X11_DISPLAY=:N WIN_ID=NNN)"
requires:
vars: [WIN_ID]
vars:
X_DISPLAY: '{{.X11_DISPLAY | default .GAMECOMP_DISPLAY}}'
cmds:
- |
echo "Requesting focus on window {{.WIN_ID}} via {{.X_DISPLAY}}"
DISPLAY={{.X_DISPLAY}} xprop -root -format GAMESCOPECTRL_BASELAYER_WINDOW 32c \
-set GAMESCOPECTRL_BASELAYER_WINDOW {{.WIN_ID}}
x11:focus-display:
desc: "Set which display receives input focus (X11_DISPLAY=:N TARGET=server_idx)"
requires:
vars: [TARGET]
vars:
X_DISPLAY: '{{.X11_DISPLAY | default .GAMECOMP_DISPLAY}}'
cmds:
- |
echo "Setting focus display to server {{.TARGET}} via {{.X_DISPLAY}}"
DISPLAY={{.X_DISPLAY}} xprop -root -format GAMESCOPE_FOCUS_DISPLAY 32c \
-set GAMESCOPE_FOCUS_DISPLAY {{.TARGET}}
x11:set-fps:
desc: "Set FPS limit at runtime (X11_DISPLAY=:N FPS=NNN)"
requires:
vars: [FPS]
vars:
X_DISPLAY: '{{.X11_DISPLAY | default .GAMECOMP_DISPLAY}}'
cmds:
- |
echo "Setting FPS limit to {{.FPS}} via {{.X_DISPLAY}}"
DISPLAY={{.X_DISPLAY}} xprop -root -format GAMESCOPE_FPS_LIMIT 32c \
-set GAMESCOPE_FPS_LIMIT {{.FPS}}
x11:set-resolution:
desc: "Set resolution for a server (X11_DISPLAY=:N SERVER=idx W=width H=height)"
requires:
vars: [SERVER, W, H]
vars:
X_DISPLAY: '{{.X11_DISPLAY | default .GAMECOMP_DISPLAY}}'
cmds:
- |
echo "Setting server {{.SERVER}} to {{.W}}x{{.H}} via {{.X_DISPLAY}}"
DISPLAY={{.X_DISPLAY}} xprop -root -format GAMESCOPE_XWAYLAND_MODE_CONTROL 32c \
-set GAMESCOPE_XWAYLAND_MODE_CONTROL {{.SERVER}},{{.W}},{{.H}},0
x11:atoms:
desc: "Dump all GAMESCOPE_* atoms from root window (X11_DISPLAY=:N)"
vars:
X_DISPLAY: '{{.X11_DISPLAY | default .GAMECOMP_DISPLAY}}'
cmds:
- |
echo "=== GAMESCOPE atoms on {{.X_DISPLAY}} ==="
DISPLAY={{.X_DISPLAY}} xprop -root 2>/dev/null | grep -E '^(GAMESCOPE|GAMESCOPECTRL|STEAM)_' || \
echo "(no gamecomp server on {{.X_DISPLAY}})"
x11:set-steam-game:
desc: "Set STEAM_GAME on a window (X11_DISPLAY=:N WIN_ID=0xNNN APP_ID=NNN)"
requires:
vars: [WIN_ID, APP_ID]
vars:
X_DISPLAY: '{{.X11_DISPLAY | default .GAMECOMP_DISPLAY}}'
cmds:
- |
echo "Setting STEAM_GAME={{.APP_ID}} on window {{.WIN_ID}} via {{.X_DISPLAY}}"
DISPLAY={{.X_DISPLAY}} xprop -id {{.WIN_ID}} -format STEAM_GAME 32c \
-set STEAM_GAME {{.APP_ID}}
x11:remove-steam-game:
desc: "Remove STEAM_GAME from a window (X11_DISPLAY=:N WIN_ID=0xNNN)"
requires:
vars: [WIN_ID]
vars:
X_DISPLAY: '{{.X11_DISPLAY | default .GAMECOMP_DISPLAY}}'
cmds:
- |
echo "Removing STEAM_GAME from window {{.WIN_ID}} via {{.X_DISPLAY}}"
DISPLAY={{.X_DISPLAY}} xprop -id {{.WIN_ID}} -format STEAM_GAME 32c \
-remove STEAM_GAME
x11:set-baselayer-appid:
desc: "Set GAMESCOPECTRL_BASELAYER_APPID on root window (X11_DISPLAY=:N APP_IDS='769,770')"
requires:
vars: [APP_IDS]
vars:
X_DISPLAY: '{{.X11_DISPLAY | default .GAMECOMP_DISPLAY}}'
cmds:
- |
echo "Setting GAMESCOPECTRL_BASELAYER_APPID={{.APP_IDS}} on root window via {{.X_DISPLAY}}"
DISPLAY={{.X_DISPLAY}} xprop -root -format GAMESCOPECTRL_BASELAYER_APPID 32c \
-set GAMESCOPECTRL_BASELAYER_APPID {{.APP_IDS}}
x11:remove-baselayer-appid:
desc: "Remove GAMESCOPECTRL_BASELAYER_APPID from root window (X11_DISPLAY=:N)"
vars:
X_DISPLAY: '{{.X11_DISPLAY | default .GAMECOMP_DISPLAY}}'
cmds:
- |
echo "Removing GAMESCOPECTRL_BASELAYER_APPID from root window via {{.X_DISPLAY}}"
DISPLAY={{.X_DISPLAY}} xprop -root -format GAMESCOPECTRL_BASELAYER_APPID 32c \
-remove GAMESCOPECTRL_BASELAYER_APPID
loc:
desc: Count lines of Rust source code
cmds:
- "find src -name '*.rs' | xargs wc -l | tail -1"
deps:
desc: Show dependency tree
cmds:
- cargo tree --depth 1
bloat:
desc: Show binary size breakdown (requires cargo-bloat)
cmds:
- cargo bloat --release -n 20
dist:prepare:
desc: Prepare the project for packaging
deps:
- build
cmds:
- rm -rf .cache/{{.NAME}}
- mkdir -p .cache/{{.NAME}}/usr/bin
- install -D -m 755 ./target/release/{{.NAME}} .cache/{{.NAME}}/usr/bin
- install -D -m 644 ./LICENSE .cache/{{.NAME}}/usr/share/{{.NAME}}/LICENSE
- mkdir -p dist
dist:archive:
desc: Build a tar archive of the project
deps:
- dist:prepare
cmds:
- tar cvfz dist/{{.NAME}}-{{.ARCH}}.tar.gz -C .cache {{.NAME}}
dist:rpm:
desc: Build an RPM package
aliases:
- rpm
deps:
- dist:archive
preconditions:
- sh: which rpmbuild
msg: "Prerequisite utility 'rpmbuild' is not installed"
cmds:
- mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
- cp ./pkg/rpm/{{.NAME}}.spec ~/rpmbuild/SPECS
- cp dist/{{.NAME}}-{{.ARCH}}.tar.gz ~/rpmbuild/SOURCES
- rpmbuild -bb --target {{.ARCH}} ~/rpmbuild/SPECS/{{.NAME}}.spec
- cp ~/rpmbuild/RPMS/{{.ARCH}}/{{.NAME}}-{{.VERSION}}-0.{{.ARCH}}.rpm dist
dist:all:
desc: Build all distributable packages
aliases:
- dist
cmds:
- task: dist:archive
- task: dist:rpm
release:
desc: Publish a new release via semantic-release
preconditions:
- sh: which npx
msg: "Prerequisite utility 'npx' is not installed"
cmds:
- npx semantic-release
docker:build:
desc: Build the container image used for docker:run
preconditions:
- sh: which docker
msg: "Prerequisite utility 'docker' is not installed"
status:
- docker images | grep {{.IMAGE_NAME}} | grep {{.IMAGE_TAG}}
cmds:
- docker build -t {{.IMAGE_NAME}}:{{.IMAGE_TAG}} .
docker:run:
desc: "Run tasks inside Docker. E.g. go-task docker:run TARGET=ci"
aliases:
- in-docker
deps:
- docker:build
preconditions:
- sh: which docker
msg: "Prerequisite utility 'docker' is not installed"
vars:
UID:
sh: id -u
GID:
sh: id -g
PWD:
sh: pwd
requires:
vars:
- TARGET
cmds:
- mkdir -p .cache/cargo .cache/home
- |
docker run --rm \
-v "{{.PWD}}:{{.PWD}}" \
-v "{{.PWD}}/.cache/cargo:/usr/local/cargo/registry" \
-v "{{.PWD}}/.cache/home:/home/build" \
--tmpfs /tmp/xdg:rw,exec,nosuid \
-e XDG_RUNTIME_DIR=/tmp/xdg \
-e HOME=/home/build \
--workdir "{{.PWD}}" \
--user {{.UID}}:{{.GID}} \
{{.IMAGE_NAME}}:{{.IMAGE_TAG}} \
task {{.TARGET}}