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
|
#!/bin/sh
set -ex
export GTK_A11Y=NONE
cleanup(){
kill -9 "$xpid" || :
rm "$exe" || :
}
trap cleanup 0
exe=$(dirname "$0")/3buttons
#shellcheck disable=SC2046
cc "$exe.c" -o "$exe" $(pkg-config --cflags --libs libpanel-1 gtk4)
#Run program in virtual X framebuffer.
export DISPLAY=:71
Xvfb "$DISPLAY" &
xpid=$!
"$exe" &
pid=$!
#Wait a bit for server to be set up and window, to be mapped
sleep 5
#The panel has merely 3 buttons. Clicking a button destroys that button.
#If 0 buttons exist, the program terminates with 0.
#Therefore, after three <Tab> <Enter>, the program terminates
i=0
nbuttons=3
while [ "$i" -lt "$nbuttons" ]; do
test -d "/proc/$pid"
xdotool key Tab Return
sleep 5
i=$((i+1))
done
#Confirm the program terminated
! kill -0 "$pid"
|