#!/bin/sh
# init=/usr/bin/desk-shell : the whole desktop: compositor, then the shell (pomelo-panel: menu bar, Dock, wallpaper,
# window list), the calculator and a Windows program.  DESK_RUN_SECONDS (default 60) ends 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 2
[ -n "${DESK_WITH_CALC:-1}" ] && { /usr/bin/pomelo-calc 2>/tmp/calc.log & }
[ -n "${DESK_WITH_NOTES:-1}" ] && { /usr/bin/pe_load /usr/bin/hello15.exe 2>/tmp/notes.log & }
N=${DESK_RUN_SECONDS:-60}; t=0
while [ $t -lt $N ] && kill -0 $cpid 2>/dev/null; do sleep 1; t=$((t+1)); done
echo "desk-shell: compositor alive=$(kill -0 $cpid 2>/dev/null && echo yes || echo no) panel alive=$(kill -0 $ppid 2>/dev/null && echo yes || echo no)"
echo "--- panel log"; tail -15 /tmp/panel.log
echo "--- compositor log"; tail -6 /tmp/compositor.log
kill $ppid $cpid 2>/dev/null; wait
exit 0
