Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gnome extension #2398

Open
wants to merge 70 commits into
base: master
from
Open
Changes from 15 commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
289f5db
Initial gnome desktop extension
diddledan Nov 8, 2018
64914e8
add extensions to schema/snapcraft.yaml
diddledan Nov 8, 2018
bf68218
spelling error in desktop-exports script from desktop extension
diddledan Nov 8, 2018
f0da7d8
appease shellcheck
diddledan Nov 8, 2018
1ba844e
Merge branch 'master' into desktop-gnome-extension
sergiusens Nov 11, 2018
23595d3
refactor gnome extension
diddledan Jan 7, 2019
58a7efc
Merge branch 'desktop-gnome-extension' of github.com:diddledan/snapcr…
diddledan Jan 7, 2019
0c85fb3
Merge branch 'master' of https://github.com/snapcore/snapcraft into d…
diddledan Jan 7, 2019
87fd118
merge desktop extension script
diddledan Jan 7, 2019
89a2db9
fix references to content interfaces paths
diddledan Jan 7, 2019
54215e3
add shared snap mountpoints and update launcher
diddledan Jan 7, 2019
ae2e4c5
squash test errors
diddledan Jan 7, 2019
e845f79
fix GIO modules symlinks; update gnome-extension
diddledan Jan 8, 2019
ab8285b
add layout to fix libwebkitgtk
diddledan Jan 8, 2019
844e6e1
Merge branch 'master' into desktop-gnome-extension
diddledan Jan 8, 2019
5d14973
set environment in command-chain scripts
diddledan Jan 14, 2019
e83ec34
fix gnome extension for core/core16 usage
diddledan Jan 14, 2019
80ab417
fix gnome extension usage of 'nil' plugin
diddledan Jan 14, 2019
61111ac
ensure static tests pass for gnome extension
diddledan Jan 14, 2019
4d24738
fix bugs in gnome extension scripts
diddledan Jan 15, 2019
6a301ca
Initial gnome desktop extension
diddledan Nov 8, 2018
a5642d2
add extensions to schema/snapcraft.yaml
diddledan Nov 8, 2018
478f7d2
spelling error in desktop-exports script from desktop extension
diddledan Nov 8, 2018
58121d1
appease shellcheck
diddledan Nov 8, 2018
1836ba5
refactor gnome extension
diddledan Jan 7, 2019
e06d7ec
merge desktop extension script
diddledan Jan 7, 2019
5f091b9
fix references to content interfaces paths
diddledan Jan 7, 2019
601d71f
add shared snap mountpoints and update launcher
diddledan Jan 7, 2019
9bf1939
squash test errors
diddledan Jan 7, 2019
745cd43
fix GIO modules symlinks; update gnome-extension
diddledan Jan 8, 2019
f668e50
add layout to fix libwebkitgtk
diddledan Jan 8, 2019
aa917d4
set environment in command-chain scripts
diddledan Jan 14, 2019
7e25ef9
fix gnome extension for core/core16 usage
diddledan Jan 14, 2019
72b2bd0
fix gnome extension usage of 'nil' plugin
diddledan Jan 14, 2019
4054ef4
ensure static tests pass for gnome extension
diddledan Jan 14, 2019
8fd0c49
fix bugs in gnome extension scripts
diddledan Jan 15, 2019
53ed8bc
further refinements to gnome extension
diddledan Jan 18, 2019
728ac4d
Fix GDK Pixbuf loaders
diddledan Jan 19, 2019
aed7404
Merge branch 'desktop-gnome-extension' of github.com:diddledan/snapcr…
diddledan Jan 19, 2019
5a6ff32
Update extensions/desktop-common/desktop-common
diddledan Jan 22, 2019
ddd64ce
update extensions/gnome/desktop-gnome-specific
diddledan Jan 22, 2019
16247ab
Add bindtextdomain for localisations
diddledan Jan 22, 2019
6aa832f
Desktop extension: Fix bindtextdomain.so build
diddledan Jan 23, 2019
d3afb53
Add locale-langpack path to bindtextdomain.c
diddledan Jan 25, 2019
cdafbe2
Add iso-codes layout to gnome extension
diddledan Feb 12, 2019
fa73f54
Merge remote-tracking branch 'origin/master' into desktop-gnome-exten…
diddledan Feb 12, 2019
21787d2
Merge branch 'master' into desktop-gnome-extension
sergiusens Feb 13, 2019
04e059e
ci: shallow clones for CLA checks on travis
sergiusens Feb 19, 2019
5092330
Merge remote-tracking branch 'origin/master' into desktop-gnome-exten…
sergiusens Feb 19, 2019
5b37480
rename gnome extension to gnome-3-28
diddledan Feb 19, 2019
e1361d0
Minor syntax errors on gnome-3-28 extension
diddledan Feb 20, 2019
712c0d8
incorrect quote style in extensions/_utils.py
diddledan Feb 20, 2019
0720c4d
force supported_cores to be a tuple in gnome ext
diddledan Feb 20, 2019
9f31943
Merge branch 'master' into desktop-gnome-extension
sergiusens Feb 20, 2019
1ecd076
Backport ubuntu/snapcraft-desktop-helpers#176
diddledan Mar 15, 2019
8b9084f
Merge branch 'master' of https://github.com/snapcore/snapcraft into d…
diddledan Mar 15, 2019
723257d
Merge branch 'desktop-gnome-extension' of github.com:diddledan/snapcr…
diddledan Mar 15, 2019
364960e
Gnome extension: variable name changes
diddledan Mar 24, 2019
3f5ec4f
Extensions: refactor away gnome exceptions
diddledan Mar 24, 2019
31b92f5
Gnome extension: remove duplicate test
diddledan Mar 24, 2019
ab20600
Desktop extensions: Remove -mark-and-exec script
diddledan Mar 24, 2019
d9aacdf
Gnome extension: Remove unused dependency vars
diddledan Mar 24, 2019
2c133da
Extensions: spelling mistake in error message
diddledan Mar 26, 2019
fd9cdd9
Gnome extension: Remove fedora $SNAP override
diddledan Apr 17, 2019
6c46d4b
Gnome extension: Fix missed var change
diddledan Apr 17, 2019
0347854
Gnome extension: Dont add empties to XDG_*_PATHS
diddledan Apr 17, 2019
11a90b4
Merge branch 'master' into desktop-gnome-extension
diddledan Apr 17, 2019
27c30c2
Gnome extension: Attempt to resolve double-frees
diddledan Apr 17, 2019
136e210
Merge branch 'desktop-gnome-extension' of github.com:diddledan/snapcr…
diddledan Apr 17, 2019
e6e6503
Desktop extensions: last-updated move to common
diddledan Apr 17, 2019
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+821 −0
Diff settings

Always

Just for now

No changes.
No changes.
No changes.
@@ -0,0 +1,390 @@
#!/bin/bash

#################
# Launcher init #
#################

# On Fedora $SNAP is under /var and there is some magic to map it to /snap.
# # We need to handle that case and reset $SNAP
SNAP="${SNAP/\/var\/lib\/snapd/}"
This conversation was marked as resolved by diddledan

This comment has been minimized.

Copy link
@sergiusens

sergiusens Feb 22, 2019

Collaborator

Can we get a better code comment for this?
We need to test this on Fedora

This comment has been minimized.

Copy link
@diddledan

diddledan Apr 17, 2019

Author Contributor

This has been dropped for now in changeset fd9cdd9.

This conversation was marked as resolved by diddledan

This comment has been minimized.

Copy link
@niemeyer

niemeyer Mar 23, 2019

This seems very strange on first sight. There are reasons why $SNAP points elsewhere in Fedora, and those reasons are trusted by snaps in general. That change breaks the common interface of snapd itself, and can easily break down other things in the system. On the other hand, internally in the snap, /snap still exists, and $SNAP should point to /snap already if it's not a classic snap, so if that's not the case today we have a bug in snapd. If it is a classic snap, then it points elsewhere because /snap may not exist, which means there's not a good reason for it to point there anyway.

Can someone please clarify these issues with the snapd team?

This comment has been minimized.

Copy link
@diddledan

diddledan Mar 24, 2019

Author Contributor

This bit of code is from the ubuntu/snapcraft-desktop-helpers repo. I don't know why it's needed but I also don't know for certain that it isn't, so I left it in place.

This comment has been minimized.

Copy link
@niemeyer

niemeyer Mar 26, 2019

If we are going to err, let's err on the safe side and drop this logic. Per rationale above, this is a fundamental setting made available to every snap by snapd. It shouldn't be hacked like this by first-class command chain scripts.

This comment has been minimized.

Copy link
@diddledan

diddledan Apr 17, 2019

Author Contributor

changeset fd9cdd9 removes this.


needs_update="true"

# shellcheck source=/dev/null
. "$SNAP_USER_DATA/.last_revision" 2>/dev/null || true
if [ "$SNAP_DESKTOP_LAST_REVISION" = "$SNAP_REVISION" ]; then
needs_update="false"
fi

# Set $REALHOME to the users real home directory
REALHOME="$(getent passwd $UID | cut -d ':' -f 6)"

# Create config folder
mkdir -p "$XDG_CONFIG_HOME" && chmod 700 "$XDG_CONFIG_HOME"

# If the user has modified their user-dirs settings, force an update
if [[ -f "$XDG_CONFIG_HOME/user-dirs.dirs.md5sum" && -f "$XDG_CONFIG_HOME/user-dirs.locale.md5sum" ]]; then
if [[ "$(md5sum < "$REALHOME/.config/user-dirs.dirs")" != "$(cat "$XDG_CONFIG_HOME/user-dirs.dirs.md5sum")" ||
"$(md5sum < "$REALHOME/.config/user-dirs.locale")" != "$(cat "$XDG_CONFIG_HOME/user-dirs.locale.md5sum")" ]]; then
needs_update="true"
fi
fi

export DESKTOP_LAUNCHER_NEEDS_UPDATE="$needs_update"

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

if [ -f "$SNAP/lib/bindtextdomain.so" ]; then
export LD_PRELOAD="$LD_PRELOAD:$SNAP/lib/bindtextdomain.so"
This conversation was marked as resolved by diddledan

This comment has been minimized.

Copy link
@oSoMoN

oSoMoN Jan 22, 2019

Contributor

bindtextdomain.so is not built. I guess the extension needs to add a part that builds it.

This comment has been minimized.

Copy link
@diddledan

diddledan Jan 22, 2019

Author Contributor

that's a direct copy+pasta from the desktop-helpers. Is bindtextdomain.so in the platform snap I wonder...

This comment has been minimized.

Copy link
@diddledan

diddledan Jan 22, 2019

Author Contributor

aha. found it :-) added in 16247ab.

fi

###############################################
# Launcher common exports for any desktop app #
###############################################

function prepend_dir() {
local var="$1"
local dir="$2"
if [ -d "$dir" ]; then
eval "export $var=\"\$dir\${$var:+:\$$var}\""
fi
}

function append_dir() {
local var="$1"
local dir="$2"
if [ -d "$dir" ]; then
eval "export $var=\"\${$var:+\$$var:}\$dir\""
fi
}

function can_open_file() {
head -c0 "$1" &> /dev/null
return $?
}

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="$(eval echo \$"${var}")"
This conversation was marked as resolved by diddledan

This comment has been minimized.

Copy link
@oSoMoN

oSoMoN Jan 10, 2019

Contributor

As pointed out by @kyrofa, you're missing some improvements from the work done for the glib extension. Specifically, this horrible eval thing can be replaced by the much safer and more elegant:

value="${!var}"

I don't remember what other improvements were made, can you please have a quick look at the glib extension PR and apply relevant changes from there?

EDIT: one of the improvements was renaming variables in a consistent way, which I thought improved quite a bit readability, e.g. "needs_update" was renamed "SNAP_DESKTOP_COMPONENTS_NEED_UPDATE". I'd suggest replicating that here.

This comment has been minimized.

Copy link
@diddledan

diddledan Jan 14, 2019

Author Contributor

fixed.


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
}

RUNTIME="$SNAP/gnome-platform"

# EGL vendor files on glvnd enabled systems
[ -d /var/lib/snapd/lib/glvnd/egl_vendor.d ] && \
append_dir __EGL_VENDOR_LIBRARY_DIRS /var/lib/snapd/lib/glvnd/egl_vendor.d

# Create XDG_DATA_HOME
mkdir -p "$XDG_DATA_HOME"

# Create cache folder
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
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" && chmod 700 "$XDG_RUNTIME_DIR"

# 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_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 "$REALHOME/.config/user-dirs.dirs" && can_open_file "$REALHOME/.config/user-dirs.locale"; then
if [ "$DESKTOP_LAUNCHER_NEEDS_UPDATE" = "true" ] || [ $needs_xdg_reload = true ]; then
sed "/^#/!s#\$HOME#${REALHOME}#g" "$REALHOME/.config/user-dirs.dirs" > "$XDG_CONFIG_HOME/user-dirs.dirs"
cp -a "$REALHOME/.config/user-dirs.locale" "$XDG_CONFIG_HOME"
for f in user-dirs.dirs user-dirs.locale; do
md5sum < "$REALHOME/.config/$f" > "$XDG_CONFIG_HOME/$f.md5sum"
done
needs_xdg_reload=true
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 if we can actually read the contents of each xdg dir
for ((i = 0; i < ${#XDG_SPECIAL_DIRS_PATHS[@]}; i++)); do
if ! can_open_file "${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
for ((i = 0; i < ${#XDG_SPECIAL_DIRS_PATHS[@]}; i++)); do
b="$(realpath "${XDG_SPECIAL_DIRS_PATHS[$i]}" --relative-to="$HOME")"
if [ -e "$REALHOME/$b" ]; then
[ -d "$HOME/$b" ] && rmdir "$HOME/$b" 2> /dev/null
[ ! -e "$HOME/$b" ] && ln -s "$REALHOME/$b" "$HOME/$b"
fi
done
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")" != "$new" ]; 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
wayland_available=true
# create the compat symlink for now
if [ ! -e "$wayland_snappath" ]; then
ln -s "$wayland_sockpath" "$wayland_snappath"
fi
fi
fi

export DESKTOP_LAUNCHER_WAYLAND_AVAILABLE="$wayland_available"

# 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

# Keep an array of data dirs, for looping through them
IFS=':' read -r -a data_dirs_array <<< "$XDG_DATA_DIRS"

function make_user_fontconfig {
echo "<fontconfig>"
if [ -d "$REALHOME/.local/share/fonts" ]; then
echo " <dir>$REALHOME/.local/share/fonts</dir>"
fi
if [ -d "$REALHOME/.fonts" ]; then
echo " <dir>$REALHOME/.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
echo ' <include ignore_missing="yes">conf.d</include>'
# We need to include this default cachedir first so that caching
# works: without it, fontconfig will try to write to the real user home
# cachedir and be blocked by AppArmor.
echo ' <cachedir prefix="xdg">fontconfig</cachedir>'
if [ -d "$REALHOME/.cache/fontconfig" ]; then
echo " <cachedir>$REALHOME/.cache/fontconfig</cachedir>"
fi
echo "</fontconfig>"
}

if [ "$DESKTOP_LAUNCHER_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.
mkdir -p "$XDG_CONFIG_HOME/fontconfig"
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_DIR which has connected themes.
ln -sf "$SNAP/data-dir/themes" "$XDG_DATA_HOME"
ln -sfn "$SNAP/data-dir/themes" "$SNAP_USER_DATA/.themes"
fi

# Build mime.cache
# needed for gtk and qt icon
if [ "$DESKTOP_LAUNCHER_NEEDS_UPDATE" = "true" ]; then
rm -rf "$XDG_DATA_HOME/mime"
if [ ! -f "$RUNTIME/usr/share/mime/mime.cache" ]; then
if command -v update-mime-database >/dev/null; then
cp --preserve=timestamps -dR "$RUNTIME/usr/share/mime" "$XDG_DATA_HOME"
update-mime-database "$XDG_DATA_HOME/mime"
fi
fi
fi

# Gio modules and cache (including gsettings module)
if [ "$DESKTOP_LAUNCHER_NEEDS_UPDATE" = "true" ]; then
if [ -f "$RUNTIME/usr/lib/$SNAP_LAUNCHER_ARCH_TRIPLET/glib-2.0/gio-querymodules" ]; then
rm -rf "$GIO_MODULE_DIR"
mkdir -p "$GIO_MODULE_DIR"
ln -sf "$RUNTIME/usr/lib/$SNAP_LAUNCHER_ARCH_TRIPLET/gio/modules/"*.so "$GIO_MODULE_DIR"
ln -sf "$SNAP/usr/lib/$SNAP_LAUNCHER_ARCH_TRIPLET/gio/modules/"*.so "$GIO_MODULE_DIR"
"$RUNTIME/usr/lib/$SNAP_LAUNCHER_ARCH_TRIPLET/glib-2.0/gio-querymodules" "$GIO_MODULE_DIR"
fi
fi

# Setup compiled gsettings schema
function compile_schemas {
if [ -f "$1" ]; then
rm -rf "$GS_SCHEMA_DIR"
mkdir -p "$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 [ "$DESKTOP_LAUNCHER_NEEDS_UPDATE" = "true" ]; then
compile_schemas "$RUNTIME/usr/lib/$SNAP_LAUNCHER_ARCH_TRIPLET/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 "$REALHOME/.config/dconf/user" ]; then
mkdir -p "$DCONF_DEST_USER_DIR"
ln -s "$REALHOME/.config/dconf/user" "$DCONF_DEST_USER_DIR"
fi
fi


# Gdk-pixbuf loaders
if [ "$DESKTOP_LAUNCHER_NEEDS_UPDATE" = "true" ]; then
rm -f "$GDK_PIXBUF_MODULE_FILE"
if [ -f "$RUNTIME/usr/lib/$SNAP_LAUNCHER_ARCH_TRIPLET/gdk-pixbuf-2.0/gdk-pixbuf-query-loaders" ]; then
"$RUNTIME/usr/lib/$SNAP_LAUNCHER_ARCH_TRIPLET/gdk-pixbuf-2.0/gdk-pixbuf-query-loaders" > "$GDK_PIXBUF_MODULE_FILE"
fi
fi

# Icon themes cache
if [ "$DESKTOP_LAUNCHER_NEEDS_UPDATE" = "true" ]; then
rm -rf "$XDG_DATA_HOME/icons"
mkdir -p "$XDG_DATA_HOME/icons"
for ((i = 0; i < ${#data_dirs_array[@]}; i++)); do
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
mkdir -p "$theme_dir"
ln -s "$theme"/* "$theme_dir"
if [ -f "$RUNTIME/usr/sbin/update-icon-caches" ]; then
"$RUNTIME/usr/sbin/update-icon-caches" "$theme_dir"
elif [ -f "$RUNTIME/usr/sbin/update-icon-cache.gtk2" ]; then
"$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/bookmarks gtk-2.0/gtkfilechooser.ini)
for f in "${gtk_configs[@]}"; do
dest="$XDG_CONFIG_HOME/$f"
if [ ! -L "$dest" ]; then
mkdir -p "$(dirname "$dest")"
ln -s "$REALHOME/.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)
mkdir -p "$IBUS_CONFIG_PATH"
[ -d "$IBUS_CONFIG_PATH/bus" ] && rm -rf "$IBUS_CONFIG_PATH/bus"
ln -sfn "$REALHOME/.config/ibus/bus" "$IBUS_CONFIG_PATH"

exec "$@"
This conversation was marked as resolved by diddledan

This comment has been minimized.

Copy link
@niemeyer

niemeyer Mar 23, 2019

Besides these minor comments, the code overall in this wrapper feels reasonable and easy to maintain working over time.

Oops, something went wrong.
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.