#!/bin/sh
# init=/usr/bin/desk-desktop : compositor + panel (wallpaper, menu bar, taskbar) + pomelo-desktop (the desktop icons).
# The wallpaper comes from ~/.config/pomelo/settings.conf (desktop.wallpaper = ...; the default depends on the layout: see docs/WALLPAPERS.md).
# DESK_DESKTOP_SECONDS ends the run (default 90).
. /usr/bin/desk-env
echo "desk-desktop: config at start: $(cat $XDG_CONFIG_HOME/pomelo/settings.conf 2>/dev/null | tr '\n' ';')"
/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 1
/usr/bin/pomelo-desktop 2>/tmp/desktop.log &
dpid=$!
N=${DESK_DESKTOP_SECONDS:-90}; t=0
while [ $t -lt $N ] && kill -0 $cpid 2>/dev/null; do sleep 1; t=$((t+1)); done
echo "desk-desktop: compositor alive=$(kill -0 $cpid 2>/dev/null && echo yes || echo no) panel alive=$(kill -0 $ppid 2>/dev/null && echo yes || echo no) desktop alive=$(kill -0 $dpid 2>/dev/null && echo yes || echo no)"
echo "--- desktop log"; tail -15 /tmp/desktop.log
echo "--- panel log"; tail -8 /tmp/panel.log
echo "--- compositor log"; tail -6 /tmp/compositor.log
kill $dpid $ppid $cpid 2>/dev/null; wait
exit 0
