#!/bin/sh
# Plasma launcher (scripts/after-pack.cjs). The Electron binary is plasma.bin.
HERE="$(dirname "$(readlink -f "$0")")"
BIN="$HERE/plasma.bin"
if [ -n "$APPIMAGE" ] && [ ! -u "$HERE/chrome-sandbox" ]; then
  blocked=0
  [ "$(cat /proc/sys/kernel/apparmor_restrict_unprivileged_userns 2>/dev/null)" = "1" ] && blocked=1
  [ "$(cat /proc/sys/kernel/unprivileged_userns_clone 2>/dev/null)" = "0" ] && blocked=1
  [ "$(cat /proc/sys/user/max_user_namespaces 2>/dev/null)" = "0" ] && blocked=1
  if [ "$blocked" = "1" ]; then
    echo "Plasma: this system blocks the Chromium sandbox for AppImages, so Plasma starts without it. Install the .deb package to keep the sandbox." >&2
    exec "$BIN" --no-sandbox "$@"
  fi
fi
exec "$BIN" "$@"
