#!/usr/bin/env bash set -euo pipefail # Script Name: rpi-flasher # Description: Launch Raspberry Pi Imager via XWayland # AppImage only bundles xcb (X11) plugin, needs XWayland on Wayland sessions export DISPLAY="${DISPLAY:-:0}" # Find XWayland auth file if XAUTHORITY isn't set if [ -z "${XAUTHORITY:-}" ]; then for f in /run/user/"$(id -u)"/xauth_*; do [ -f "$f" ] && export XAUTHORITY="$f" && break done fi # Allow root to connect (needed when imager escalates via pkexec to write SD card) xhost +si:localuser:root 2>/dev/null || true # Copy xauth cookie to ~/.Xauthority so pkexec'd root process can find it xauth extract - "$DISPLAY" 2>/dev/null | xauth -f "$HOME/.Xauthority" merge - 2>/dev/null || true QT_QPA_PLATFORM=xcb /home/e/opt/raspberrypi/imager_2.0.6_amd64.AppImage "$@"