SmartFox: launcher, Siri Remote driver, Debian image and installer
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
25
tools/vm/hotswap.sh
Normal file
25
tools/vm/hotswap.sh
Normal file
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env bash
|
||||
# Rebuilds SmartFox binaries in WSL and swaps them into the running VM (no image rebuild).
|
||||
# hotswap.sh sf-remote sf-launcher
|
||||
set -euo pipefail
|
||||
SRC=/mnt/g/source/smartfox
|
||||
WORK=/root/smartfox
|
||||
VM="$WORK/tools/vm"
|
||||
rsync -a --chmod=Du=rwx,Dgo=rx,Fu=rw,Fgo=r \
|
||||
--exclude /target --exclude /image/mkosi.output --exclude /image/mkosi.cache --exclude /image/stage --exclude /image/ovmf-vars.fd \
|
||||
"$SRC/" "$WORK/"
|
||||
cd "$WORK"
|
||||
args=()
|
||||
for c in "$@"; do args+=(-p "$c"); done
|
||||
~/.cargo/bin/cargo build --release "${args[@]}" 2>&1 | grep -E "^(error|warning)|-->|Finished" -A6 || true
|
||||
for c in "$@"; do
|
||||
bash "$VM/vmcp.sh" "target/release/$c" "vm:/usr/bin/$c.new"
|
||||
bash "$VM/vmssh.sh" "mv /usr/bin/$c.new /usr/bin/$c && chmod 755 /usr/bin/$c"
|
||||
done
|
||||
for c in "$@"; do
|
||||
case "$c" in
|
||||
sf-remote) bash "$VM/vmssh.sh" "systemctl restart sf-remote" ;;
|
||||
sf-launcher) bash "$VM/vmssh.sh" "pkill -x sf-launcher || true; systemctl restart getty@tty1" ;;
|
||||
esac
|
||||
done
|
||||
echo "swapped: $*"
|
||||
7
tools/vm/screenshot.sh
Normal file
7
tools/vm/screenshot.sh
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
# Saves a screenshot of the QEMU VM display (PNG) via the monitor socket.
|
||||
# usage: screenshot.sh /path/out.png
|
||||
OUT="${1:-/root/vm-shot.png}"
|
||||
echo "screendump $OUT -f png" | socat - UNIX-CONNECT:/root/qemu-monitor.sock >/dev/null
|
||||
sleep 0.5
|
||||
ls -la "$OUT"
|
||||
10
tools/vm/start-vm.ps1
Normal file
10
tools/vm/start-vm.ps1
Normal file
@@ -0,0 +1,10 @@
|
||||
# Starts the SmartFox OS VM (QEMU in WSL Debian). The window appears via WSLg.
|
||||
# powershell -File tools\vm\start-vm.ps1 # boot the last built image
|
||||
# powershell -File tools\vm\start-vm.ps1 -Build # rebuild image first
|
||||
param([switch]$Build, [string]$Bt = "")
|
||||
if ($Build) {
|
||||
wsl -d Debian -u root -- bash /mnt/g/source/smartfox/image/build.sh
|
||||
}
|
||||
$extra = ""
|
||||
if ($Bt) { $extra = "--bt $Bt" }
|
||||
wsl -d Debian -u root -- bash -c "cd /root/smartfox && bash image/run-qemu.sh $extra"
|
||||
7
tools/vm/vmcp.sh
Normal file
7
tools/vm/vmcp.sh
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copies files to/from the SmartFox VM. Use "vm:" prefix for the remote side.
|
||||
# vmcp.sh local vm:/remote vmcp.sh vm:/remote local
|
||||
OPTS=(-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR -P 2222)
|
||||
args=()
|
||||
for a in "$@"; do args+=("${a/#vm:/root@localhost:}"); done
|
||||
exec sshpass -p smartfox scp "${OPTS[@]}" "${args[@]}"
|
||||
14
tools/vm/vmkey.sh
Normal file
14
tools/vm/vmkey.sh
Normal file
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
# Sends key presses to the VM through the QEMU monitor (like a real keyboard).
|
||||
# vmkey.sh esc ret f12 vmkey.sh --hold esc 1.2
|
||||
if [ "$1" = "--hold" ]; then
|
||||
# QEMU sendkey with a hold time in ms
|
||||
ms=$(awk "BEGIN {print int(${3:-1} * 1000)}")
|
||||
echo "sendkey $2 $ms" | socat - UNIX-CONNECT:/root/qemu-monitor.sock >/dev/null
|
||||
sleep "${3:-1}"
|
||||
exit 0
|
||||
fi
|
||||
for k in "$@"; do
|
||||
echo "sendkey $k" | socat - UNIX-CONNECT:/root/qemu-monitor.sock >/dev/null
|
||||
sleep 0.3
|
||||
done
|
||||
10
tools/vm/vmshot.sh
Normal file
10
tools/vm/vmshot.sh
Normal file
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
# Screenshot of the VM's Wayland session (needs grim in the VM).
|
||||
# vmshot.sh /local/out.png
|
||||
D="$(dirname "$0")"
|
||||
OUT="${1:-/root/vm-shot.png}"
|
||||
if ! "$D/vmssh.sh" 'command -v grim >/dev/null || test -x /usr/local/bin/grim'; then
|
||||
"$D/vmcp.sh" /usr/bin/grim vm:/usr/local/bin/grim
|
||||
fi
|
||||
"$D/vmssh.sh" 'G=$(command -v grim || echo /usr/local/bin/grim); runuser -u tv -- env XDG_RUNTIME_DIR=/run/user/1000 WAYLAND_DISPLAY=wayland-0 "$G" /tmp/shot.png' &&
|
||||
"$D/vmcp.sh" vm:/tmp/shot.png "$OUT" && echo "saved $OUT"
|
||||
12
tools/vm/vmssh.sh
Normal file
12
tools/vm/vmssh.sh
Normal file
@@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
# Runs a command in the SmartFox QEMU VM (dev image, root/smartfox).
|
||||
# usage: vmssh.sh [--wait] 'command'
|
||||
OPTS=(-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR -p 2222)
|
||||
if [ "$1" = "--wait" ]; then
|
||||
shift
|
||||
for _ in $(seq 1 60); do
|
||||
sshpass -p smartfox ssh "${OPTS[@]}" -o ConnectTimeout=3 root@localhost true 2>/dev/null && break
|
||||
sleep 2
|
||||
done
|
||||
fi
|
||||
exec sshpass -p smartfox ssh "${OPTS[@]}" root@localhost "$@"
|
||||
Reference in New Issue
Block a user