-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathdesktop-exports
500 lines (438 loc) · 19.3 KB
/
desktop-exports
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
#!/bin/bash
###############################################
# 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`.
function prepend_dir() {
local -n var="$1"
local dir="$2"
# We can't check if the dir exists when the dir contains variables
if [[ "$dir" == *"\$"* || -d "$dir" ]]; then
export "${!var}=${dir}${var:+:$var}"
fi
}
function append_dir() {
local -n var="$1"
local dir="$2"
# We can't check if the dir exists when the dir contains variables
if [[ "$dir" == *"\$"* || -d "$dir" ]]; then
export "${!var}=${var:+$var:}${dir}"
fi
}
function can_open_file() {
[ -f "$1" ] && [ -r "$1" ]
}
function update_xdg_dirs_values() {
local save_initial_values=false
local XDG_DIRS="DOCUMENTS DESKTOP DOWNLOAD MUSIC PICTURES VIDEOS PUBLICSHARE TEMPLATES"
unset XDG_SPECIAL_DIRS_PATHS
if [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/user-dirs.dirs" ]; then
# shellcheck source=/dev/null
source "${XDG_CONFIG_HOME:-$HOME/.config}/user-dirs.dirs"
fi
if [ -z ${XDG_SPECIAL_DIRS+x} ]; then
save_initial_values=true
fi
for d in $XDG_DIRS; do
var="XDG_${d}_DIR"
value="${!var}"
if [ "$save_initial_values" = true ]; then
XDG_SPECIAL_DIRS+=("$var")
XDG_SPECIAL_DIRS_INITIAL_PATHS+=("$value")
fi
XDG_SPECIAL_DIRS_PATHS+=("$value")
done
}
function is_subpath() {
dir="$(realpath "$1")"
parent="$(realpath "$2")"
[ "${dir##"${parent}"/}" != "${dir}" ] && return 0 || return 1
}
if ! snapctl is-connected "%PLATFORM_PLUG%"; then
echo "ERROR: not connected to the %PLATFORM_PLUG% content interface."
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"
append_dir LD_LIBRARY_PATH "$SNAP_DESKTOP_RUNTIME/lib"
append_dir PATH "$SNAP_DESKTOP_RUNTIME/usr/bin"
# XKB config
export XKB_CONFIG_ROOT="$SNAP_DESKTOP_RUNTIME/usr/share/X11/xkb"
# Set XCursors path
export XCURSOR_PATH="$SNAP_DESKTOP_RUNTIME/usr/share/icons"
prepend_dir XCURSOR_PATH "$SNAP/data-dir/icons"
# 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
# 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"
# Pulseaudio export
append_dir LD_LIBRARY_PATH "$SNAP_DESKTOP_RUNTIME/usr/lib/$ARCH/pulseaudio"
# 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/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
prepend_dir XDG_CONFIG_DIRS "$SNAP_DESKTOP_RUNTIME/etc/xdg"
prepend_dir XDG_CONFIG_DIRS "$SNAP/etc/xdg"
# Define snaps' own data dir
prepend_dir XDG_DATA_DIRS "$SNAP_DESKTOP_RUNTIME/usr/share"
prepend_dir XDG_DATA_DIRS "$SNAP/usr/share"
prepend_dir XDG_DATA_DIRS "$SNAP/share"
prepend_dir XDG_DATA_DIRS "$SNAP/data-dir"
prepend_dir XDG_DATA_DIRS "$SNAP_USER_DATA"
# Set XDG_DATA_HOME to local path
export XDG_DATA_HOME="$SNAP_USER_DATA/.local/share"
ensure_dir_exists "$XDG_DATA_HOME"
# Workaround for GLib < 2.53.2 not searching for schemas in $XDG_DATA_HOME:
# https://bugzilla.gnome.org/show_bug.cgi?id=741335
prepend_dir XDG_DATA_DIRS "$XDG_DATA_HOME"
# Set cache folder to local path
export XDG_CACHE_HOME="$SNAP_USER_COMMON/.cache"
if [[ -d "$SNAP_USER_DATA/.cache" && ! -e "$XDG_CACHE_HOME" ]]; then
# the .cache directory used to be stored under $SNAP_USER_DATA, migrate it
mv "$SNAP_USER_DATA/.cache" "$SNAP_USER_COMMON/"
fi
ensure_dir_exists "$XDG_CACHE_HOME"
# Create $XDG_RUNTIME_DIR if not exists (to be removed when LP: #1656340 is fixed)
# shellcheck disable=SC2174
ensure_dir_exists "$XDG_RUNTIME_DIR" -m 700
# Ensure the app finds locale definitions (requires locales-all to be installed)
append_dir LOCPATH "$SNAP_DESKTOP_RUNTIME/usr/lib/locale"
# If any, keep track of where XDG dirs were so we can potentially migrate the content later
update_xdg_dirs_values
# Setup user-dirs.* or run xdg-user-dirs-update if needed
needs_xdg_update=false
needs_xdg_reload=false
needs_xdg_links=false
if [ "$HOME" != "$SNAP_REAL_HOME" ] && [ "$HOME" != "$SNAP_USER_DATA" ] && ! is_subpath "$XDG_CONFIG_HOME" "$HOME"; then
for f in user-dirs.dirs user-dirs.locale; do
if [ -f "$HOME/.config/$f" ]; then
mv "$HOME/.config/$f" "$XDG_CONFIG_HOME"
needs_xdg_reload=true
fi
done
fi
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 [ "$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"
# It's possible user-dirs.dirs exists when user-dirs.locale doesn't. This
# simply means the user opted to never ask to translate their user dirs
if can_open_file "$SNAP_REAL_HOME/.config/user-dirs.locale"; then
cp -a "$SNAP_REAL_HOME/.config/user-dirs.locale" "$XDG_CONFIG_HOME"
md5sum < "$SNAP_REAL_HOME/.config/user-dirs.locale" > "$XDG_CONFIG_HOME/user-dirs.locale.md5sum"
elif [ -f "$XDG_CONFIG_HOME/user-dirs.locale.md5sum" ]; then
rm "$XDG_CONFIG_HOME/user-dirs.locale.md5sum"
fi
needs_xdg_reload=true
fi
fi
else
needs_xdg_update=true
needs_xdg_links=true
fi
if [ $needs_xdg_reload = true ]; then
update_xdg_dirs_values
needs_xdg_reload=false
fi
# Check existance of each xdg dir
for ((i = 0; i < ${#XDG_SPECIAL_DIRS_PATHS[@]}; i++)); do
if [ ! -d "${XDG_SPECIAL_DIRS_PATHS[$i]}" ]; then
needs_xdg_update=true
needs_xdg_links=true
break
fi
done
# If needs XDG update and xdg-user-dirs-update exists in $PATH, run it
if [ "$needs_xdg_update" = true ] && command -v xdg-user-dirs-update >/dev/null; then
xdg-user-dirs-update
update_xdg_dirs_values
fi
# Create links for user-dirs.dirs
if [ "$needs_xdg_links" = true ]; then
if [ "$HOME" != "$SNAP_REAL_HOME" ]; then
for ((i = 0; i < ${#XDG_SPECIAL_DIRS_PATHS[@]}; i++)); do
b="$(realpath "${XDG_SPECIAL_DIRS_PATHS[$i]}" --relative-to="$HOME" 2>/dev/null)"
if [[ -n "$b" && "$b" != "." && -e "$SNAP_REAL_HOME/$b" ]]; then
[ -d "$HOME/$b" ] && rmdir "$HOME/$b" 2> /dev/null
[ ! -e "$HOME/$b" ] && ln -s "$SNAP_REAL_HOME/$b" "$HOME/$b"
fi
done
fi
else
# If we aren't creating new links, check if we have content saved in old locations and move it
for ((i = 0; i < ${#XDG_SPECIAL_DIRS[@]}; i++)); do
old="${XDG_SPECIAL_DIRS_INITIAL_PATHS[$i]}"
new="${XDG_SPECIAL_DIRS_PATHS[$i]}"
if [ -L "$old" ] && [ -d "$new" ] && [ "$(readlink "$old" 2>/dev/null)" != "$new" ] &&
(is_subpath "$old" "$SNAP_USER_DATA" || is_subpath "$old" "$SNAP_USER_COMMON"); then
mv -vn "$old"/* "$new"/ 2>/dev/null
elif [ -d "$old" ] && [ -d "$new" ] && [ "$old" != "$new" ] &&
(is_subpath "$old" "$SNAP_USER_DATA" || is_subpath "$old" "$SNAP_USER_COMMON"); then
mv -vn "$old"/* "$new"/ 2>/dev/null
fi
done
fi
# 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
# Applications that don't support wayland natively may define DISABLE_WAYLAND
# (to any non-empty value) to skip that logic entirely.
wayland_available=false
if [[ -n "$XDG_RUNTIME_DIR" && -z "$DISABLE_WAYLAND" ]]; 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
# shellcheck disable=SC2034
wayland_available=true
# create the compat symlink for now
if [ ! -e "$wayland_snappath" ]; then
ln -s "$wayland_sockpath" "$wayland_snappath"
fi
fi
fi
# Make PulseAudio socket available inside the snap-specific $XDG_RUNTIME_DIR
if [ -n "$XDG_RUNTIME_DIR" ]; then
pulsenative="pulse/native"
pulseaudio_sockpath="$XDG_RUNTIME_DIR/../$pulsenative"
if [ -S "$pulseaudio_sockpath" ]; then
export PULSE_SERVER="unix:${pulseaudio_sockpath}"
fi
fi
# GI repository
prepend_dir GI_TYPELIB_PATH "$SNAP_DESKTOP_RUNTIME/usr/lib/$ARCH/girepository-1.0"
prepend_dir GI_TYPELIB_PATH "$SNAP_DESKTOP_RUNTIME/usr/lib/girepository-1.0"
prepend_dir GI_TYPELIB_PATH "$SNAP_DESKTOP_RUNTIME/usr/lib/gjs/girepository-1.0"
prepend_dir GI_TYPELIB_PATH "$SNAP/usr/lib/$ARCH/girepository-1.0"
prepend_dir GI_TYPELIB_PATH "$SNAP/usr/lib/girepository-1.0"
prepend_dir GI_TYPELIB_PATH "$SNAP/usr/lib/gjs/girepository-1.0"
# Keep an array of data dirs, for looping through them
IFS=':' read -r -a data_dirs_array <<< "$XDG_DATA_DIRS"
# Font Config and themes
export FONTCONFIG_PATH="$SNAP_DESKTOP_RUNTIME/etc/fonts"
export FONTCONFIG_FILE="$SNAP_DESKTOP_RUNTIME/etc/fonts/fonts.conf"
function make_user_fontconfig {
echo "<fontconfig>"
if [ -d "$SNAP_REAL_HOME/.local/share/fonts" ]; then
echo " <dir>$SNAP_REAL_HOME/.local/share/fonts</dir>"
fi
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.
echo ' <cachedir prefix="xdg">fontconfig</cachedir>'
echo " <cachedir>$SNAP_COMMON/fontconfig</cachedir>"
echo "</fontconfig>"
}
if [ "$needs_update" = true ]; then
rm -rf "$XDG_DATA_HOME"/{fontconfig,fonts,fonts-*,themes,.themes}
# This fontconfig fragment is installed in a location that is
# included by the system fontconfig configuration: namely the
# etc/fonts/conf.d/50-user.conf file.
ensure_dir_exists "$XDG_CONFIG_HOME/fontconfig"
async_exec make_user_fontconfig > "$XDG_CONFIG_HOME/fontconfig/fonts.conf"
# the themes symlink are needed for GTK 3.18 when the prefix isn't changed
# GTK 3.20 looks into XDG_DATA_DIRS which has connected themes.
if [ -d "$SNAP/data-dir/themes" ]; then
ln -sf "$SNAP/data-dir/themes" "$XDG_DATA_HOME"
ln -sfn "$SNAP/data-dir/themes" "$SNAP_USER_DATA/.themes"
elif [ -d "$SNAP_DESKTOP_RUNTIME/usr/share/themes" ]; then
ln -sf "$SNAP_DESKTOP_RUNTIME/usr/share/themes" "$XDG_DATA_HOME"
ln -sfn "$SNAP_DESKTOP_RUNTIME/usr/share/themes" "$SNAP_USER_DATA/.themes"
fi
fi
# Build mime.cache
# needed for gtk and qt icon
if [ "$needs_update" = true ]; then
rm -rf "$XDG_DATA_HOME/mime"
if [ ! -f "$SNAP_DESKTOP_RUNTIME/usr/share/mime/mime.cache" ]; then
if command -v update-mime-database >/dev/null; then
cp --preserve=timestamps -dR "$SNAP_DESKTOP_RUNTIME/usr/share/mime" "$XDG_DATA_HOME"
async_exec update-mime-database "$XDG_DATA_HOME/mime"
fi
fi
fi
# 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"
ensure_dir_exists "$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
async_exec compile_giomodules "$SNAP_DESKTOP_RUNTIME/usr/lib/$ARCH"
fi
# 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"
ensure_dir_exists "$GS_SCHEMA_DIR"
for ((i = 0; i < ${#data_dirs_array[@]}; i++)); do
schema_dir="${data_dirs_array[$i]}/glib-2.0/schemas"
if [ -f "$schema_dir/gschemas.compiled" ]; then
# This directory already has compiled schemas
continue
fi
if [ -n "$(ls -A "$schema_dir"/*.xml 2>/dev/null)" ]; then
ln -s "$schema_dir"/*.xml "$GS_SCHEMA_DIR"
fi
if [ -n "$(ls -A "$schema_dir"/*.override 2>/dev/null)" ]; then
ln -s "$schema_dir"/*.override "$GS_SCHEMA_DIR"
fi
done
# Only compile schemas if we copied anything
if [ -n "$(ls -A "$GS_SCHEMA_DIR"/*.xml "$GS_SCHEMA_DIR"/*.override 2>/dev/null)" ]; then
"$1" "$GS_SCHEMA_DIR"
fi
fi
}
if [ "$needs_update" = true ]; then
async_exec compile_schemas "$SNAP_DESKTOP_RUNTIME/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 "$SNAP_REAL_HOME/.config/dconf/user" ]; then
ensure_dir_exists "$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
if [ -r "$XDG_RUNTIME_DIR/../dconf/user" ]; then
ensure_dir_exists "$XDG_RUNTIME_DIR/dconf"
ln -sf "../../dconf/user" "$XDG_RUNTIME_DIR/dconf/user"
fi
# Testability support
append_dir LD_LIBRARY_PATH "$SNAP/testability"
append_dir LD_LIBRARY_PATH "$SNAP/testability/$ARCH"
append_dir LD_LIBRARY_PATH "$SNAP/testability/$ARCH/mesa"
# Gdk-pixbuf loaders
export GDK_PIXBUF_MODULE_FILE="$XDG_CACHE_HOME/gdk-pixbuf-loaders.cache"
export GDK_PIXBUF_MODULEDIR="$SNAP_DESKTOP_RUNTIME/usr/lib/$ARCH/gdk-pixbuf-2.0/2.10.0/loaders"
if [ "$needs_update" = true ] || [ ! -f "$GDK_PIXBUF_MODULE_FILE" ]; then
rm -f "$GDK_PIXBUF_MODULE_FILE"
if [ -f "$SNAP_DESKTOP_RUNTIME/usr/lib/$ARCH/gdk-pixbuf-2.0/gdk-pixbuf-query-loaders" ]; then
async_exec "$SNAP_DESKTOP_RUNTIME/usr/lib/$ARCH/gdk-pixbuf-2.0/gdk-pixbuf-query-loaders" > "$GDK_PIXBUF_MODULE_FILE"
fi
fi
# Icon themes cache
if [ "$needs_update" = true ]; then
rm -rf "$XDG_DATA_HOME/icons"
ensure_dir_exists "$XDG_DATA_HOME/icons"
for ((i = 0; i < ${#data_dirs_array[@]}; i++)); do
# The runtime and theme content snaps should already contain icon caches
# 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
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")"
if [ ! -d "$theme_dir" ]; then
ensure_dir_exists "$theme_dir"
ln -s "$theme"/* "$theme_dir"
if [ -f "$SNAP_DESKTOP_RUNTIME/usr/sbin/update-icon-caches" ]; then
async_exec "$SNAP_DESKTOP_RUNTIME/usr/sbin/update-icon-caches" "$theme_dir"
elif [ -f "$SNAP_DESKTOP_RUNTIME/usr/sbin/update-icon-cache.gtk2" ]; then
async_exec "$SNAP_DESKTOP_RUNTIME/usr/sbin/update-icon-cache.gtk2" "$theme_dir"
fi
fi
fi
done
done
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/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 "$SNAP_REAL_HOME/.config/$f" "$dest"
fi
done
# create symbolic link to ibus socket path for ibus to look up its socket files
# (see comments #3 and #6 on https://launchpad.net/bugs/1580463)
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 "$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"