#!/bin/sh
# init=/usr/bin/desk-comdlg cdlg=<open|multi|save|color|font|opena>: the compositor, then ct_comdlg.exe with that dialog.
. /usr/bin/desk-env
MODE=$(sed -n 's/.*cdlg=\([a-z]*\).*/\1/p' /proc/cmdline)
/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
/usr/bin/pe_load -v /usr/bin/ct_comdlg.exe ${MODE:-open} &
epid=$!
N=${DESK_RUN_SECONDS:-100}; t=0
while [ $t -lt $N ] && kill -0 $epid 2>/dev/null; do sleep 1; t=$((t+1)); done
if kill -0 $epid 2>/dev/null; then ended=no; else ended=yes; wait $epid; echo "desk-comdlg: exe exit status $?"; sleep 3; fi
echo "desk-comdlg: ended=$ended"
kill $epid $cpid 2>/dev/null; wait
exit 0
