@@ -65,6 +65,31 @@ mkdir -p $XDG_CACHE_HOME
# Create $XDG_RUNTIME_DIR if not exists (to be removed when LP: #1656340 is fixed)
[ -n "$XDG_RUNTIME_DIR" ] && mkdir -p $XDG_RUNTIME_DIR -m 700
+# If detect wayland server socket, then set environment so applications prefer
+# wayland, and setup compat symlink (until we use user mounts. Remember,
+# XDG_RUNTIME_DIR is /run/user/<uid>/snap.$SNAP so look in the parent directory
+# for the socket. For details:
+# https://forum.snapcraft.io/t/wayland-dconf-and-xdg-runtime-dir/186/10
+if [ -n "$XDG_RUNTIME_DIR" ]; then
+ wdisplay="wayland-0"
+ if [ -n "$WAYLAND_DISPLAY" ]; then
+ wdisplay="$WAYLAND_DISPLAY"
+ fi
+ wayland_sockpath="$XDG_RUNTIME_DIR/../$wdisplay"
+ wayland_snappath="$XDG_RUNTIME_DIR/$wdisplay"
+ if [ -S "$wayland_sockpath" ]; then
+ # if running under wayland, use it
+ #export WAYLAND_DEBUG=1
+ export GDK_BACKEND="wayland"
+ export CLUTTER_BACKEND="wayland"
+ export QT_QPA_PLATFORM="wayland-egl"
+ # create the compat symlink for now
+ if [ ! -e "$wayland_snappath" ]; then
+ ln -s "$wayland_sockpath" "$wayland_snappath"
+ fi
+ fi
+fi
+
# GI repository
export GI_TYPELIB_PATH=$RUNTIME/usr/lib/girepository-1.0:$RUNTIME/usr/lib/$ARCH/girepository-1.0
[ "$WITH_RUNTIME" = yes ] && GI_TYPELIB_PATH=$SNAP/usr/lib/girepository-1.0:$SNAP/usr/lib/$ARCH/girepository-1.0 # add local SNAP assets if a runtime is used
0 comments on commit
c19eff0