[neon/snap-packaging/snapcraft-desktop-integration] common: Update desktop-exports.

Scarlett Moore null at kde.org
Tue Nov 19 10:20:20 GMT 2024


Git commit b2f9b1e8c7c5d72424d06c09e7c49ededd7579a9 by Scarlett Moore.
Committed on 19/11/2024 at 10:19.
Pushed by scarlettmoore into branch 'master'.

Update desktop-exports.

M  +74   -54   common/desktop-exports

https://invent.kde.org/neon/snap-packaging/snapcraft-desktop-integration/-/commit/b2f9b1e8c7c5d72424d06c09e7c49ededd7579a9

diff --git a/common/desktop-exports b/common/desktop-exports
index 1027d68..19ff4bb 100644
--- a/common/desktop-exports
+++ b/common/desktop-exports
@@ -1,10 +1,7 @@
 #!/bin/bash
-###########################################################
-# Launcher common exports for any desktop app
-# This is not used with the gnome extension for
-# core22 and later, please see
-# https://github.com/snapcore/snapcraft-desktop-integration
-###########################################################
+###############################################
+# Launcher common exports for any desktop app #
+###############################################
 
 # Note: We avoid using `eval` because we don't want to expand variable names
 #       in paths. For example: LD_LIBRARY_PATH paths might contain `$LIB`.
@@ -68,6 +65,11 @@ if ! snapctl is-connected "%PLATFORM_PLUG%"; then
   exit 1
 fi
 
+# Use keyfile storage if gsettings isn't accessible
+if ! snapctl is-connected gsettings 2>/dev/null; then
+  export GSETTINGS_BACKEND=keyfile
+fi
+
 append_dir LD_LIBRARY_PATH "$SNAP_DESKTOP_RUNTIME/lib/$ARCH"
 append_dir LD_LIBRARY_PATH "$SNAP_DESKTOP_RUNTIME/usr/lib/$ARCH"
 append_dir LD_LIBRARY_PATH "$SNAP_DESKTOP_RUNTIME/usr/lib"
@@ -77,40 +79,48 @@ append_dir PATH "$SNAP_DESKTOP_RUNTIME/usr/bin"
 # XKB config
 export XKB_CONFIG_ROOT="$SNAP_DESKTOP_RUNTIME/usr/share/X11/xkb"
 
-# Give XOpenIM a chance to locate locale data.
-# This is required for text input to work in SDL2 games.
-export XLOCALEDIR="$SNAP_DESKTOP_RUNTIME/usr/share/X11/locale"
-
 # Set XCursors path
 export XCURSOR_PATH="$SNAP_DESKTOP_RUNTIME/usr/share/icons"
 prepend_dir XCURSOR_PATH "$SNAP/data-dir/icons"
 
-# Mesa Libs for OpenGL support
-append_dir LD_LIBRARY_PATH "$SNAP_DESKTOP_RUNTIME/usr/lib/$ARCH/mesa"
-append_dir LD_LIBRARY_PATH "$SNAP_DESKTOP_RUNTIME/usr/lib/$ARCH/mesa-egl"
-
-# Tell libGL and libva where to find the drivers
-export LIBGL_DRIVERS_PATH="$SNAP_DESKTOP_RUNTIME/usr/lib/$ARCH/dri"
-append_dir LD_LIBRARY_PATH "$LIBGL_DRIVERS_PATH"
-append_dir LIBVA_DRIVERS_PATH "$SNAP_DESKTOP_RUNTIME/usr/lib/$ARCH/dri"
-
-# Set where the VDPAU drivers are located
-export VDPAU_DRIVER_PATH="/usr/lib/$ARCH/vdpau/"
-if [ -e "/var/lib/snapd/lib/gl/vdpau/libvdpau_nvidia.so" ]; then
-  export VDPAU_DRIVER_PATH="/var/lib/snapd/lib/gl/vdpau"
-  if [ "$__NV_PRIME_RENDER_OFFLOAD" = 1 ]; then
-    # Prevent picking VA-API (Intel/AMD) over NVIDIA VDPAU
-    # https://download.nvidia.com/XFree86/Linux-x86_64/510.54/README/primerenderoffload.html#configureapplications
-    unset LIBVA_DRIVERS_PATH
+# Unless told to defer to the gpu interface
+# https://mir-server.io/docs/the-gpu-2404-snap-interface
+if [ "%WITH_GRAPHICS%" != "false" ]; then
+  # Give XOpenIM a chance to locate locale data.
+  # This is required for text input to work in SDL2 games.
+  export XLOCALEDIR="$SNAP_DESKTOP_RUNTIME/usr/share/X11/locale"
+
+  # Mesa Libs for OpenGL support
+  append_dir LD_LIBRARY_PATH "$SNAP_DESKTOP_RUNTIME/usr/lib/$ARCH/mesa"
+  append_dir LD_LIBRARY_PATH "$SNAP_DESKTOP_RUNTIME/usr/lib/$ARCH/mesa-egl"
+
+  # Tell libGL and libva where to find the drivers
+  export LIBGL_DRIVERS_PATH="$SNAP_DESKTOP_RUNTIME/usr/lib/$ARCH/dri"
+  append_dir LD_LIBRARY_PATH "$LIBGL_DRIVERS_PATH"
+  append_dir LIBVA_DRIVERS_PATH "$SNAP_DESKTOP_RUNTIME/usr/lib/$ARCH/dri"
+
+  # Set where the VDPAU drivers are located
+  export VDPAU_DRIVER_PATH="/usr/lib/$ARCH/vdpau/"
+  if [ -e "/var/lib/snapd/lib/gl/vdpau/libvdpau_nvidia.so" ]; then
+    export VDPAU_DRIVER_PATH="/var/lib/snapd/lib/gl/vdpau"
+    if [ "$__NV_PRIME_RENDER_OFFLOAD" = 1 ]; then
+      # Prevent picking VA-API (Intel/AMD) over NVIDIA VDPAU
+      # https://download.nvidia.com/XFree86/Linux-x86_64/510.54/README/primerenderoffload.html#configureapplications
+      unset LIBVA_DRIVERS_PATH
+    fi
   fi
-fi
 
-# Workaround in snapd for proprietary nVidia drivers mounts the drivers in
-# /var/lib/snapd/lib/gl that needs to be in LD_LIBRARY_PATH
-# Without that OpenGL using apps do not work with the nVidia drivers.
-# Ref.: https://bugs.launchpad.net/snappy/+bug/1588192
-append_dir LD_LIBRARY_PATH "/var/lib/snapd/lib/gl"
-append_dir LD_LIBRARY_PATH "/var/lib/snapd/lib/gl/vdpau"
+  # Workaround in snapd for proprietary nVidia drivers mounts the drivers in
+  # /var/lib/snapd/lib/gl that needs to be in LD_LIBRARY_PATH
+  # Without that OpenGL using apps do not work with the nVidia drivers.
+  # Ref.: https://bugs.launchpad.net/snappy/+bug/1588192
+  append_dir LD_LIBRARY_PATH "/var/lib/snapd/lib/gl"
+  append_dir LD_LIBRARY_PATH "/var/lib/snapd/lib/gl/vdpau"
+
+  # EGL vendor files on glvnd enabled systems
+  prepend_dir __EGL_VENDOR_LIBRARY_DIRS "/var/lib/snapd/lib/glvnd/egl_vendor.d"
+  append_dir __EGL_VENDOR_LIBRARY_DIRS "$SNAP_DESKTOP_RUNTIME/usr/share/glvnd/egl_vendor.d"
+fi
 
 # Unity7 export (workaround for https://launchpad.net/bugs/1638405)
 append_dir LD_LIBRARY_PATH "$SNAP_DESKTOP_RUNTIME/usr/lib/$ARCH/libunity"
@@ -118,21 +128,18 @@ append_dir LD_LIBRARY_PATH "$SNAP_DESKTOP_RUNTIME/usr/lib/$ARCH/libunity"
 # Pulseaudio export
 append_dir LD_LIBRARY_PATH "$SNAP_DESKTOP_RUNTIME/usr/lib/$ARCH/pulseaudio"
 
-# EGL vendor files on glvnd enabled systems
-prepend_dir __EGL_VENDOR_LIBRARY_DIRS "/var/lib/snapd/lib/glvnd/egl_vendor.d"
-append_dir __EGL_VENDOR_LIBRARY_DIRS "$SNAP_DESKTOP_RUNTIME/usr/share/glvnd/egl_vendor.d"
+# Tell Pipewire where to find its configuration and plugins
+export PIPEWIRE_CONFIG_DIR="$SNAP_DESKTOP_RUNTIME/usr/share/pipewire"
+export PIPEWIRE_MODULE_DIR="$SNAP_DESKTOP_RUNTIME/usr/lib/$ARCH/pipewire-0.3"
+export SPA_PLUGIN_DIR="$SNAP_DESKTOP_RUNTIME/usr/lib/$ARCH/spa-0.2"
 
 # Tell GStreamer where to find its plugins
-export GST_PLUGIN_PATH="$SNAP_DESKTOP_RUNTIME/usr/lib/$ARCH/gstreamer-1.0"
+export GST_PLUGIN_PATH="$SNAP/usr/lib/$ARCH/gstreamer-1.0"
 export GST_PLUGIN_SYSTEM_PATH="$SNAP_DESKTOP_RUNTIME/usr/lib/$ARCH/gstreamer-1.0"
 # gst plugin scanner doesn't install in the correct path: https://github.com/ubuntu/snapcraft-desktop-helpers/issues/43
 export GST_PLUGIN_SCANNER="$SNAP_DESKTOP_RUNTIME/usr/lib/$ARCH/gstreamer1.0/gstreamer-1.0/gst-plugin-scanner"
 
 # XDG Config
-# KConfig uses QStandardPaths:GenericConfigLocation to get the config dir paths
-# and checks for the kdeglobals file there for theming. The kdeglobals file is
-# stored in $SNAP_REAL_HOME/.config folder.
-prepend_dir XDG_CONFIG_DIRS "$SNAP_REAL_HOME/.config"
 prepend_dir XDG_CONFIG_DIRS "$SNAP_DESKTOP_RUNTIME/etc/xdg"
 prepend_dir XDG_CONFIG_DIRS "$SNAP/etc/xdg"
 
@@ -183,9 +190,9 @@ if [ "$HOME" != "$SNAP_REAL_HOME" ] && [ "$HOME" != "$SNAP_USER_DATA" ] && ! is_
   done
 fi
 
-if can_open_file "$REALHOME/.config/user-dirs.dirs"; then
+if can_open_file "$SNAP_REAL_HOME/.config/user-dirs.dirs"; then
   # shellcheck disable=SC2154
-   if [ "$XDG_CONFIG_HOME" != "$SNAP_REAL_HOME/.config" ]; then
+  if [ "$XDG_CONFIG_HOME" != "$SNAP_REAL_HOME/.config" ]; then
     if [ "$needs_update" = true ] || [ "$needs_xdg_reload" = true ]; then
       sed "/^#/!s#\$HOME#${SNAP_REAL_HOME}#g" "$SNAP_REAL_HOME/.config/user-dirs.dirs" > "$XDG_CONFIG_HOME/user-dirs.dirs"
       md5sum < "$SNAP_REAL_HOME/.config/user-dirs.dirs" > "$XDG_CONFIG_HOME/user-dirs.dirs.md5sum"
@@ -304,17 +311,24 @@ export FONTCONFIG_FILE="$SNAP_DESKTOP_RUNTIME/etc/fonts/fonts.conf"
 
 function make_user_fontconfig {
   echo "<fontconfig>"
-  if [ -d "$REALHOME/.local/share/fonts" ]; then
-    echo "  <dir>$REALHOME/.local/share/fonts</dir>"
+  if [ -d "$SNAP_REAL_HOME/.local/share/fonts" ]; then
+    echo "  <dir>$SNAP_REAL_HOME/.local/share/fonts</dir>"
   fi
-  if [ -d "$REALHOME/.fonts" ]; then
-    echo "  <dir>$REALHOME/.fonts</dir>"
+  if [ -d "$SNAP_REAL_HOME/.fonts" ]; then
+    echo "  <dir>$SNAP_REAL_HOME/.fonts</dir>"
   fi
   for ((i = 0; i < ${#data_dirs_array[@]}; i++)); do
     if [ -d "${data_dirs_array[$i]}/fonts" ]; then
       echo "  <dir>${data_dirs_array[$i]}/fonts</dir>"
     fi
   done
+  # The purpose of this directory is to make certain fontconfig files available
+  # to the snap environment by default. Right now it helps the transition to Noto
+  # as default font become effective in snaps used in 23.10 and 24.04 before the
+  # base snap is core24.
+  echo '  <include ignore_missing="yes">/etc/fonts/snap-override</include>'
+  # In accordance with the discussion at https://bugs.launchpad.net/bugs/2025651
+  # we don't load files from /etc/fonts/conf.d at this time.
   echo '  <include ignore_missing="yes">conf.d</include>'
   # We need to include a user-writable cachedir first to support
   # caching of per-user fonts.
@@ -402,9 +416,9 @@ fi
 # symlink the dconf file if home plug is connected for read
 DCONF_DEST_USER_DIR="$SNAP_USER_DATA/.config/dconf"
 if [ ! -f "$DCONF_DEST_USER_DIR/user" ]; then
-  if [ -f "$REALHOME/.config/dconf/user" ]; then
+  if [ -f "$SNAP_REAL_HOME/.config/dconf/user" ]; then
     ensure_dir_exists "$DCONF_DEST_USER_DIR"
-    ln -s "$REALHOME/.config/dconf/user" "$DCONF_DEST_USER_DIR"
+    ln -s "$SNAP_REAL_HOME/.config/dconf/user" "$DCONF_DEST_USER_DIR"
   fi
 fi
 # symlink the runtime dconf file as well
@@ -437,7 +451,7 @@ if [ "$needs_update" = true ]; then
     # so we skip them to optimise app start time.
     if [[ "${data_dirs_array[$i]}" == "$SNAP/data-dir" || "${data_dirs_array[$i]}" == "$SNAP_DESKTOP_RUNTIME/"* ]]; then
       continue
-    fi  
+    fi
     for theme in "${data_dirs_array[$i]}"/icons/*; do
       if [ -f "$theme/index.theme" ] && [ ! -f "$theme/icon-theme.cache" ]; then
         theme_dir="$XDG_DATA_HOME/icons/$(basename "$theme")"
@@ -457,12 +471,12 @@ fi
 
 # GTK theme and behavior modifier
 # Those can impact the theme engine used by Qt as well
-gtk_configs=(gtk-3.0/settings.ini gtk-3.0/bookmarks gtk-2.0/gtkfilechooser.ini)
+gtk_configs=(gtk-3.0/settings.ini gtk-3.0/gtk.css gtk-3.0/bookmarks gtk-2.0/gtkfilechooser.ini)
 for f in "${gtk_configs[@]}"; do
   dest="$XDG_CONFIG_HOME/$f"
   if [ ! -L "$dest" ]; then
     ensure_dir_exists "$(dirname "$dest")"
-    ln -s "$REALHOME/.config/$f" "$dest"
+    ln -s "$SNAP_REAL_HOME/.config/$f" "$dest"
   fi
 done
 
@@ -471,10 +485,16 @@ done
 IBUS_CONFIG_PATH="$XDG_CONFIG_HOME/ibus"
 ensure_dir_exists "$IBUS_CONFIG_PATH"
 [ -d "$IBUS_CONFIG_PATH/bus" ] && rm -rf "$IBUS_CONFIG_PATH/bus"
-ln -sfn "$REALHOME/.config/ibus/bus" "$IBUS_CONFIG_PATH"
+ln -sfn "$SNAP_REAL_HOME/.config/ibus/bus" "$IBUS_CONFIG_PATH"
 
 # Set libgweather path
 export LIBGWEATHER_LOCATIONS_PATH="$SNAP_DESKTOP_RUNTIME/usr/lib/$ARCH/libgweather-4/Locations.bin"
 
 # Set libthai dict path
 export LIBTHAI_DICTDIR="$SNAP_DESKTOP_RUNTIME/usr/share/libthai/"
+
+# Workaround for libproxy. It sets DT_RUNTIME to be able to find libpxbackend, which
+# isn't in the normal library path, but inside a folder. This works when the library
+# is in the default place, but not if it is snapped in the gnome-sdk/gnome-runtime snap.
+
+append_dir LD_LIBRARY_PATH "$SNAP_DESKTOP_RUNTIME/usr/lib/$ARCH/libproxy"


More information about the Neon-commits mailing list