Permalink
Browse files

Merge pull request #68 from jdstrand/use-wayland-if-available

prefer wayland if wayland detected and create compat symlink
  • Loading branch information...
2 parents b722554 + d4fab4b commit c19eff033485cbd5a81093bef1f049e351b3d699 @kenvandine kenvandine committed Aug 14, 2017
Showing with 25 additions and 0 deletions.
  1. +25 −0 common/desktop-exports
View
@@ -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

Please sign in to comment.