#!/bin/sh
# init=/usr/bin/desk-taskbar : compositor + shell (Windows 11 style taskbar), then after a few seconds a file manager,
# a terminal and the calculator so the taskbar shows running apps (dots) and one focused app (long bar).
# scripts/test-taskbar.sh drives the mouse and screenshots it.
. /usr/bin/desk-env
/usr/bin/pomelo-compositor 2>/tmp/compositor.log &
cpid=$!
i=0
while [ $i -lt 100 ] && [ ! -S "$XDG_RUNTIME_DIR/wayland-0" ]; do sleep 0.2; i=$((i+1)); done
export WAYLAND_DISPLAY=wayland-0
export XDG_DATA_DIRS=/usr/share
/usr/bin/pomelo-panel 2>/tmp/panel.log &
ppid=$!
sleep ${DESK_TB_OPEN_AT:-14}
/usr/bin/pomelo-files /c 2>/tmp/files.log &
f1=$!
sleep 3
/usr/bin/pomelo-calc 2>/tmp/calc.log &
f2=$!
sleep 3
/usr/bin/pomelo-edit 2>/tmp/term.log &
f3=$!
N=${DESK_TB_SECONDS:-90}; t=0
while [ $t -lt $N ] && kill -0 $cpid 2>/dev/null; do sleep 1; t=$((t+1)); done
echo "--- panel log"; tail -12 /tmp/panel.log
echo "--- app logs"; head -3 /tmp/files.log /tmp/calc.log /tmp/term.log
echo "--- compositor log"; tail -4 /tmp/compositor.log
kill $f3 $f2 $f1 $ppid $cpid 2>/dev/null
wait $f1 $f2 $f3 $ppid $cpid 2>/dev/null
exit 0
