#!/bin/sh
set -eu
# This launcher accepts no executable, path, command or custom port from a URL.
if [ "$#" -gt 1 ] || { [ "$#" -eq 1 ] && [ "$1" != "ilovbee-realtime://launch" ]; }; then
  exit 2
fi
if [ "$(id -u)" -eq 0 ] || [ -z "${XDG_RUNTIME_DIR:-}" ]; then
  exit 1
fi
systemctl --user daemon-reload
for variable in DISPLAY WAYLAND_DISPLAY XDG_CURRENT_DESKTOP XDG_SESSION_TYPE; do
  if printenv "$variable" >/dev/null; then
    systemctl --user import-environment "$variable"
  fi
done
systemctl --user start ilovbee-media-helper.service
