#!/usr/bin/env bash
set -euo pipefail
APP_DIR="/usr/lib/privet"
# Prefer X11 when on Wayland+NVIDIA (Flutter EGL often fails to show first frame).
if [[ "${XDG_SESSION_TYPE:-}" == "wayland" ]] && [[ -e /proc/driver/nvidia/version || -e /dev/nvidia0 ]]; then
  export GDK_BACKEND="${GDK_BACKEND:-x11}"
fi
cd "$APP_DIR"
exec "$APP_DIR/privet" "$@"
