#!/bin/sh
set -eu

# zypak maps Chromium's sandbox onto Flatpak's sandbox. CHROME_DESKTOP gives
# Chromium the exported desktop file name without modifying upstream's ASAR.
export CHROME_DESKTOP="${FLATPAK_ID}.desktop"
export TMPDIR="${XDG_RUNTIME_DIR}/app/${FLATPAK_ID}"
unset ELECTRON_RUN_AS_NODE

# The Deno runtime OpenTubeX shells out to for yt-dlp lives in /app/extra
# (staged there by apply_extra), not /app/bin, so put it on PATH.
export PATH="/app/extra:${PATH}"

exec zypak-wrapper /app/extra/opentubex/opentubex --ozone-platform-hint=auto "$@"
