File: //snap/chromium/3248/bin/daemon.wrapper
#!/bin/sh
set -e
real_xdg_runtime_dir=$(dirname "${XDG_RUNTIME_DIR}")
real_wayland=${real_xdg_runtime_dir}/${WAYLAND_DISPLAY:-wayland-0}
# Permissions applying to the deepest directory is fine
#shellcheck disable=2174
mkdir -p "$XDG_RUNTIME_DIR" -m 700
ln -sf "${real_wayland}" "$XDG_RUNTIME_DIR"
ln -sf "${real_wayland}.lock" "$XDG_RUNTIME_DIR"
unset DISPLAY
# Chromium creates a file with a unique name which indicates whether or not the
# requested profile is in-use by some other chromium process. Chromium is
# supposed to clean up after itself, but sometimes this lock file persists.
# Because we are running Chromium as a kiosk, it is safe to manually remove this
# file - the profile should not be in use.
if [ -e "$SNAP_USER_COMMON/chromium/SingletonLock" ]; then
unlink "$SNAP_USER_COMMON/chromium/SingletonLock"
fi
exec "$@"