#!/usr/bin/env bash
# =============================================================================
#  DigitalWall - Linux kiosk launcher
#  Runs the DigitalWall player full-screen in Chromium on this machine.
#
#  Usage:
#    chmod +x digitalwall-linux-kiosk.sh
#    ./digitalwall-linux-kiosk.sh
#
#  To auto-start on boot, add this script to your desktop's autostart, or
#  create a systemd --user service that runs it after the graphical session.
#  On first run, pair the screen using the 6-character code it displays.
# =============================================================================
set -e
URL="https://app.digitalwall.in/player/"

# Keep the display awake (X11)
command -v xset >/dev/null 2>&1 && { xset s off; xset -dpms; xset s noblank; } || true

FLAGS="--kiosk --app=$URL --noerrdialogs --disable-infobars --disable-session-crashed-bubble --incognito --check-for-update-interval=31536000"

if command -v chromium >/dev/null 2>&1; then
  exec chromium $FLAGS
elif command -v chromium-browser >/dev/null 2>&1; then
  exec chromium-browser $FLAGS
elif command -v google-chrome >/dev/null 2>&1; then
  exec google-chrome $FLAGS
else
  echo "No Chromium/Chrome found. Install one:  sudo apt install chromium-browser"
  exit 1
fi
