33 lines
2.4 KiB
Bash
Executable File
33 lines
2.4 KiB
Bash
Executable File
#!/bin/sh
|
|
# AnyBot on GNOME Wayland (the desktop portals), from a Mac or anywhere with Docker:
|
|
# deploy/linux/dev/gnome/test.sh (from app/, after building both images)
|
|
# A headless GNOME 43 runs in the box; op.py plays the person: it answers GNOME's
|
|
# 「遠端桌面」 dialog (switch on 「允許遠端操作」, press 「分享」) and reads the screen through
|
|
# Mutter's own screen cast. Checks: the missing-switch message, typing English + Chinese into a
|
|
# text box, and clicking a small button exactly.
|
|
set -e
|
|
cd "$(dirname "$0")/../../../.."
|
|
docker rm -f anybot-gnome >/dev/null 2>&1 || true
|
|
docker run -d --name anybot-gnome -v "$PWD":/src -v anybot-linux-target:/target -w /src anybot-linux-gnome sh -c '
|
|
mkdir -p /run/dbus; dbus-daemon --system --fork; (python3 -m dbusmock --template logind --system >/tmp/mock.log 2>&1 &); sleep 1
|
|
useradd -m t; runuser -u t -- env HOME=/home/t sh deploy/linux/dev/gnome/session.sh' >/dev/null
|
|
sleep 10
|
|
docker exec -u t anybot-gnome sh -c '
|
|
. /tmp/env.sh; OP="python3 deploy/linux/dev/gnome/op.py"; A=/target/release/anybot
|
|
# Leave the overview, and answer GNOME'"'"'s one-time "allow screenshots?" as the person would.
|
|
$OP key ff1b; sleep 1
|
|
gdbus call --session -d org.freedesktop.impl.portal.PermissionStore -o /org/freedesktop/impl/portal/PermissionStore -m org.freedesktop.impl.portal.PermissionStore.SetPermission screenshot true screenshot "" "[\"yes\"]" >/dev/null
|
|
approve() { sleep 5; [ "$1" = share-only ] || { $OP click 820 492; sleep 0.5; }; $OP click 841 289; sleep 6; }
|
|
echo "1. 分享 without 允許遠端操作:"
|
|
(timeout 60 $A --tool computer_use_screenshot {} > /tmp/a1.log 2>&1 &); approve share-only; sed "s/^/ /" /tmp/a1.log
|
|
echo "2. typing into a text box:"
|
|
(GDK_BACKEND=wayland zenity --entry --title t --text 輸入 > /tmp/zen.out 2>/dev/null &); sleep 3
|
|
(timeout 60 $A --tool computer_use_screenshot {} computer_use_typing "{\"value\":\"Hi 你好,世界 ok\"}" computer_use_press_key "{\"key\":\"return\"}" > /tmp/a2.log 2>&1 &); approve
|
|
echo " text box got: [$(cat /tmp/zen.out)] (expected [Hi 你好,世界 ok])"
|
|
echo "3. clicking 「否」 in a yes/no dialog:"
|
|
(GDK_BACKEND=wayland zenity --question --title q --text 要繼續嗎 >/dev/null 2>&1; echo "$?" > /tmp/q.out) & sleep 3
|
|
(timeout 60 $A --tool computer_use_screenshot {} computer_use_click "{\"x\":98,\"y\":168}" > /tmp/a3.log 2>&1 &); approve
|
|
echo " dialog answer: $(cat /tmp/q.out) (expected 1 = 否)"
|
|
'
|
|
docker rm -f anybot-gnome >/dev/null
|