Fix melonDS crash: use QT_QPA_PLATFORM=wayland on Wayland compositors

melonDS was crashing with "could not connect to display :0.0" because
QT_QPA_PLATFORM was hardcoded to xcb. On RK3326 with Sway (Wayland),
XWayland may not expose :0.0 for all apps.

Fix: detect WAYLAND_DISPLAY and use wayland platform automatically.
Also set UTF-8 locale (Qt6 requires it, system defaults to "C").

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Douglas Teles
2026-04-18 10:50:35 -03:00
parent 33ecd7ebaa
commit 510bfd69b1
2 changed files with 14 additions and 17 deletions
@@ -164,15 +164,15 @@ else
ROM="${1}"
fi
# QT platform - default to xcb
export QT_QPA_PLATFORM=xcb
# QT platform - use wayland on Wayland compositors, xcb otherwise
if [ -n "${WAYLAND_DISPLAY}" ]; then
export QT_QPA_PLATFORM=wayland
else
export QT_QPA_PLATFORM=xcb
fi
# QT platform - some device / driver combinations need wayland
case ${HW_DEVICE} in
RK3566|RK3588|S922X)
[[ $(/usr/bin/gpudriver) == "libmali" ]] && export QT_QPA_PLATFORM=wayland
;;
esac
# Qt requires UTF-8 locale
export LC_ALL=en_US.UTF-8 2>/dev/null || export LC_ALL=C.UTF-8
@PANFROST@
@HOTKEY@
@@ -10,14 +10,11 @@ set_kill set "-9 melonDS"
sway_fullscreen "net.kuribo64.melonDS" &
# QT platform - default to xcb
export QT_QPA_PLATFORM=xcb
# QT platform - some device / driver combinations need wayland
case ${HW_DEVICE} in
RK3566|RK3588|S922X)
[[ $(/usr/bin/gpudriver) == "libmali" ]] && export QT_QPA_PLATFORM=wayland
;;
esac
# QT platform - use wayland on Wayland compositors, xcb otherwise
if [ -n "${WAYLAND_DISPLAY}" ]; then
export QT_QPA_PLATFORM=wayland
else
export QT_QPA_PLATFORM=xcb
fi
/usr/bin/melonDS