#!/bin/sh

COMPOSITOR="/usr/bin/phoc"
PHOC_INI="/usr/share/phog/phoc.ini"

help()
{
  cat <<EOF
phog - Session start script for Phog

This is usually invoked by a display manager but you can
also run it from a tty.

Usage: phog
EOF
  exit 0
}


version()
{
   echo "0.1.3"
   exit 0
}

case "$1" in
  -h|-\?|--help)
    help
    ;;
  --version)
    version
    ;;
esac

if [ -x /usr/bin/phoc ]; then
  COMPOSITOR=/usr/bin/phoc
fi

if [ -f /etc/phog/phoc.ini ]; then
  PHOC_INI=/etc/phog/phoc.ini
fi

# Run phog through a login shell so it picks
# variables from /etc/profile.d (XDG_*)
[ -n "$WLR_BACKENDS" ] || WLR_BACKENDS=drm,libinput
export WLR_BACKENDS
exec "${COMPOSITOR}" -S -C "${PHOC_INI}" -E "bash -lc '/usr/libexec/phog & squeekboard'"
