#!/bin/sh
set -eu

# Prefer the application tree next to this launcher. This is essential for
# AppImage and development layouts: an installed system copy must not shadow
# the bundled copy that the user explicitly launched.
SCRIPT_DIR=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)
BUNDLED_MAIN=$(dirname -- "$SCRIPT_DIR")/share/big-video-converter/main.py
SYSTEM_MAIN=/usr/share/big-video-converter/main.py

if [ -f "$BUNDLED_MAIN" ]; then
    exec python3 "$BUNDLED_MAIN" "$@"
fi

if [ -f "$SYSTEM_MAIN" ]; then
    exec python3 "$SYSTEM_MAIN" "$@"
fi

printf '%s\n' 'Big Video Converter installation was not found.' >&2
exit 1
