1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209 | #!/bin/bash
###############################################
# 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=$SNAP/usr/lib/$ARCH/dri:$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
# 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 [ $needs_update = true ]; 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
if [ -f "$1" ]; then
"$1" $GS_SCHEMA_DIR
fi
fi
}
compile_schemas $SNAP/usr/lib/$ARCH/glib-2.0/glib-compile-schemas
# 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
#############################
# QT launcher specific part #
#############################
# select qt version
. $SNAP/flavor-select
# Qt Platform to Mir
export QTCHOOSER_NO_GLOBAL_DIR=1
if [ "$USE_qt5" = true ]; then
export QT_SELECT=snappy-qt5
elif [ "$USE_qt5-app-platform" = true ]; then
if [ ! -d $SNAP/ubuntu-app-platform ] ; then
echo "You need to connect the ubuntu-app-platform package with your application "
echo "to reuse shared assets, please run:"
echo "snap install ubuntu-app-platform"
echo "snap connect $SNAP_NAME:platform ubuntu-app-platform:platform"
fi
export QT_SELECT=snappy-qt5-app-platform
else
export QT_SELECT=snappy-qt4
fi
# Qt Libs and Modules
if [ "$USE_qt5" = true ]; then
export LD_LIBRARY_PATH=$SNAP/usr/lib/$ARCH/qt5/libs:$LD_LIBRARY_PATH
export QT_PLUGIN_PATH=$SNAP/usr/lib/$ARCH/qt5/plugins
export QML2_IMPORT_PATH=$QML2_IMPORT_PATH:$SNAP/usr/lib/$ARCH/qt5/qml
export QML2_IMPORT_PATH=$QML2_IMPORT_PATH:$SNAP/lib/$ARCH
elif [ "$USE_qt5-app-platform" = true ]; then
export LD_LIBRARY_PATH=$SNAP/ubuntu-app-platform/usr/lib/$ARCH/qt5/libs:$LD_LIBRARY_PATH
export QT_PLUGIN_PATH=$SNAP/ubuntu-app-platform/usr/lib/$ARCH/qt5/plugins
export QML2_IMPORT_PATH=$QML2_IMPORT_PATH:$SNAP/ubuntu-app-platform/usr/lib/$ARCH/qt5/qml
export QML2_IMPORT_PATH=$QML2_IMPORT_PATH:$SNAP/lib/$ARCH
else
export LD_LIBRARY_PATH=$SNAP/usr/lib/$ARCH/qt4:$LD_LIBRARY_PATH
export QT_PLUGIN_PATH=$SNAP/usr/lib/$ARCH/qt4/plugins
export QML_IMPORT_PATH=$QML_IMPORT_PATH:$SNAP/usr/lib/$ARCH/qt4/qml
export QML_IMPORT_PATH=$QML_IMPORT_PATH:$SNAP/lib/$ARCH
fi
# Necessary for the SDK to find the translations directory
export APP_DIR=$SNAP
# Removes Qt warning: Could not find a location
# of the system Compose files
export QTCOMPOSE=$SNAP/usr/share/X11/locale
# Use GTK styling for running under Unity 7
export GTK_PATH=$SNAP/usr/lib/$ARCH/gtk-2.0
# Gdk-pixbuf loaders
export GDK_PIXBUF_MODULE_FILE=$XDG_CACHE_HOME/gdk-pixbuf-loaders.cache
export GDK_PIXBUF_MODULEDIR=$SNAP/usr/lib/$ARCH/gdk-pixbuf-2.0/2.10.0/loaders
if [ $needs_update = true ]; then
rm -f $GDK_PIXBUF_MODULE_FILE
if [ -f $SNAP/usr/lib/$ARCH/gdk-pixbuf-2.0/gdk-pixbuf-query-loaders ]; then
$SNAP/usr/lib/$ARCH/gdk-pixbuf-2.0/gdk-pixbuf-query-loaders > $GDK_PIXBUF_MODULE_FILE
fi
fi
# Keep an array of data dirs, for looping through them
IFS=':' read -r -a data_dirs_array <<< "$XDG_DATA_DIRS"
# Icon themes cache
if [ $needs_update = true ]; then
rm -rf $XDG_DATA_HOME/icons
mkdir -p $XDG_DATA_HOME/icons
for d in "${data_dirs_array[@]}"; do
for i in $d/icons/*; do
if [ -d "$i" ]; then
theme_dir=$XDG_DATA_HOME/icons/$(basename "$i")
if [ ! -d "$theme_dir" ]; then
mkdir -p "$theme_dir"
ln -s $i/* "$theme_dir"
if [ -f $SNAP/usr/sbin/update-icon-caches ]; then
$SNAP/usr/sbin/update-icon-caches "$theme_dir"
elif [ -f $SNAP/usr/sbin/update-icon-cache.gtk2 ]; then
$SNAP/usr/sbin/update-icon-cache.gtk2 "$theme_dir"
fi
fi
fi
done
done
fi
# compile real schema files now that we have the executable as part of the platform snap
if [ "$USE_qt5-app-platform" = true ]; then
compile_schemas $SNAP/ubuntu-app-platform/usr/lib/$ARCH/glib-2.0/glib-compile-schemas
fi
exec "$@"
|