15 lines
511 B
Bash
15 lines
511 B
Bash
#!/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
|