#!/bin/bash
# We're Projectin' — open the player full screen every time this Raspberry Pi / Linux PC starts.
# Run once:  bash projectin-pi.sh
URL="${1:-https://videoplayer.imegonline.com/}"
BROWSER=$(command -v chromium-browser || command -v chromium || command -v google-chrome)
if [ -z "$BROWSER" ]; then echo "Install Chromium first: sudo apt install -y chromium-browser"; exit 1; fi
mkdir -p ~/.config/autostart
cat > ~/.config/autostart/projectin.desktop <<EOF
[Desktop Entry]
Type=Application
Name=Projectin Player
Exec=sh -c 'sleep 10; xset s off; xset -dpms; xset s noblank; $BROWSER --kiosk --noerrdialogs --disable-infobars --autoplay-policy=no-user-gesture-required --check-for-update-interval=31536000 --disable-session-crashed-bubble "$URL"'
X-GNOME-Autostart-enabled=true
EOF
# Wayland (Raspberry Pi OS Bookworm) autostart
if [ -d ~/.config/labwc ] || command -v labwc >/dev/null; then
  mkdir -p ~/.config/labwc
  grep -q projectin ~/.config/labwc/autostart 2>/dev/null || echo "sleep 10 && $BROWSER --kiosk --noerrdialogs --autoplay-policy=no-user-gesture-required \"$URL\" & # projectin" >> ~/.config/labwc/autostart
fi
echo "Done. Restart to test: sudo reboot"
echo "Also set: Raspberry Pi Configuration > System > Auto login = ON"
