#!/bin/sh
# openbox session: launch tint2 taskbar + chromium, then openbox as WM.
# This file is used as an xinitrc by bee-desktop.

# Disable screensaver and DPMS
xset s off
xset -dpms
xset s noblank

# Set desktop background.
if [ -f /usr/share/bee/wallpaper.png ]; then
    feh --bg-fill /usr/share/bee/wallpaper.png
else
    xsetroot -solid '#f6c90e'
fi

tint2 &

# Wait up to 60s for bee-web before opening Chromium.
# Without this Chromium gets connection-refused and shows a blank page.
_i=0
while [ $_i -lt 60 ]; do
    curl -sf http://localhost/healthz >/dev/null 2>&1 && break
    sleep 1
    _i=$((_i+1))
done
unset _i

chromium \
    --disable-infobars \
    --disable-translate \
    --no-first-run \
    --disable-session-crashed-bubble \
    --disable-features=TranslateUI \
    --user-data-dir=/tmp/bee-chrome \
    --start-maximized \
    http://localhost/loading &

exec openbox
