Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
130 lines (107 sloc) 3.97 KB
###############################################
# Launcher common exports for any desktop app #
###############################################
needs_update=true
. ~/.last_revision 2>/dev/null || true
if [ "$SNAP_DESKTOP_LAST_REVISION" = "$SNAP_REVISION" ]; then
needs_update=false
fi
[ $needs_update = true ] && echo "SNAP_DESKTOP_LAST_REVISION=$SNAP_REVISION" > ~/.last_revision
if [ "$SNAP_ARCH" == "amd64" ]; then
ARCH="x86_64-linux-gnu"
elif [ "$SNAP_ARCH" == "armhf" ]; then
ARCH="arm-linux-gnueabihf"
elif [ "$SNAP_ARCH" == "arm64" ]; then
ARCH="aarch64-linux-gnu"
else
ARCH="$SNAP_ARCH-linux-gnu"
fi
export SNAP_LAUNCHER_ARCH_TRIPLET=$ARCH
# XKB config
export XKB_CONFIG_ROOT=$SNAP/usr/share/X11/xkb
# Mesa Libs for OpenGL support
export LD_LIBRARY_PATH=$SNAP/usr/lib/$ARCH/mesa:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$SNAP/usr/lib/$ARCH/mesa-egl:$LD_LIBRARY_PATH
# Tell libGL where to find the drivers
export LIBGL_DRIVERS_PATH=$SNAP/usr/lib/$ARCH/dri
export LD_LIBRARY_PATH=$LIBGL_DRIVERS_PATH:$LD_LIBRARY_PATH
# Tell where to find the client libraries for Mir
export MIR_CLIENT_PLATFORM_PATH=$SNAP/usr/lib/$ARCH/mir/client-platform
# Pulseaudio export
##export LD_LIBRARY_PATH=$SNAP/usr/lib/$ARCH/pulseaudio:$LD_LIBRARY_PATH
# Tell GStreamer where to find its system plugins
export GST_PLUGIN_SYSTEM_PATH=$SNAP/usr/lib/$ARCH/gstreamer-1.0
# XDG Config
export XDG_CONFIG_DIRS=$SNAP/etc/xdg:$SNAP/usr/xdg:$XDG_CONFIG_DIRS
# Define snaps' own data dir
export XDG_DATA_DIRS=$SNAP_USER_DATA:$SNAP/usr/share:$XDG_DATA_DIRS
# Set XDG_DATA_HOME to local path
export XDG_DATA_HOME=$SNAP_USER_DATA/.local/share
export XDG_DATA_DIRS=$XDG_DATA_HOME:$XDG_DATA_DIRS
mkdir -p $XDG_DATA_HOME
# Set cache folder to local path
export XDG_CACHE_HOME=$SNAP_USER_DATA/.cache
mkdir -p $XDG_CACHE_HOME
# GI repository
export GI_TYPELIB_PATH=$SNAP/usr/lib/girepository-1.0:$SNAP/usr/lib/$ARCH/girepository-1.0
# Font Config and themes
export FONTCONFIG_PATH=$SNAP/etc/fonts/conf.d
export FONTCONFIG_FILE=$SNAP/etc/fonts/fonts.conf
if [ $needs_update = true ]; then
rm -rf $XDG_DATA_HOME/{fontconfig,fonts,fonts-*,themes,.themes}
ln -sf $SNAP/usr/share/{fontconfig,fonts,fonts-*,themes} $XDG_DATA_HOME
ln -sfn $SNAP/usr/share/themes $SNAP_USER_DATA/.themes
fi
# Build mime.cache
# needed for gtk and qt icon
if [ $needs_update = true ]; then
rm -rf $XDG_DATA_HOME/mime
if [ `which update-mime-database` ]; then
cp --preserve=timestamps -dR $SNAP/usr/share/mime $XDG_DATA_HOME
update-mime-database $XDG_DATA_HOME/mime
fi
fi
# Ensure the app finds locale definitions (requires locales-all to be installed)
export LOCPATH=$SNAP/usr/lib/locale
# Gio modules and cache (including gsettings module)
export GIO_MODULE_DIR=$XDG_CACHE_HOME/gio-modules
function compile_giomodules {
if [ -f $1/glib-2.0/gio-querymodules ]; then
rm -rf $GIO_MODULE_DIR
mkdir -p $GIO_MODULE_DIR
ln -s $1/gio/modules/*.so $GIO_MODULE_DIR
$1/glib-2.0/gio-querymodules $GIO_MODULE_DIR
fi
}
if [ $needs_update = true ]; then
compile_giomodules $SNAP/usr/lib/$ARCH
fi
# Keep an array of data dirs, for looping through them
IFS=':' read -r -a data_dirs_array <<< "$XDG_DATA_DIRS"
# Setup compiled gsettings schema
GS_SCHEMA_DIR=$XDG_DATA_HOME/glib-2.0/schemas
function compile_schemas {
if [ -f "$1" ]; then
rm -rf $GS_SCHEMA_DIR
mkdir -p $GS_SCHEMA_DIR
for d in "${data_dirs_array[@]}"; do
schema_dir=$d/glib-2.0/schemas
if [ "$(ls -A $schema_dir/*.xml 2>/dev/null)" ]; then
ln -s $schema_dir/*.xml $GS_SCHEMA_DIR
fi
done
"$1" $GS_SCHEMA_DIR
fi
}
if [ $needs_update = true ]; then
compile_schemas $SNAP/usr/lib/$ARCH/glib-2.0/glib-compile-schemas
fi
# Enable gsettings user changes
# 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 /home/$USER/.config/dconf/user ]; then
mkdir -p $DCONF_DEST_USER_DIR
ln -s /home/$USER/.config/dconf/user $DCONF_DEST_USER_DIR
fi
fi