#!/bin/sh

# Runtime-Verzeichnis sicherstellen
export XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-/run/user/$(id -u)}"

# Active Wayland-Socket ermitteln
if [ -z "$WAYLAND_DISPLAY" ] || [ ! -S "$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY" ]; then
for s in wayland-0 wayland-1 display/wayland-0; do
    if [ -S "$XDG_RUNTIME_DIR/$s" ]; then
        export WAYLAND_DISPLAY="$s"
        break
    fi
done
fi

export SDL_VIDEODRIVER=wayland
export SDL_ACCELEROMETER_AS_JOYSTICK=1
export PPSSPP_ASSET_DIR=/usr/share/ppsspp/assets
export LD_LIBRARY_PATH="/usr/lib64:/vendor/lib64:$LD_LIBRARY_PATH"

exec /usr/bin/ppsspp-bin "$@"
