#!/bin/bash
#
# SPDX-License-Identifier: MIT
#

# Source love2d runtime
source $controlfolder/runtimes/"love_11.5"/love.txt

# SO IT CAN BE STOPPED, MUAHAHAHAHAHA
export PMSPLASH_STOP="$controlfolder/utils/pmsplash/stopsplash"

[ -f "$PMSPLASH_STOP" ] && $ESUDO rm -f "$PMSPLASH_STOP"

# Run the splash
$LOVE_RUN "$controlfolder/utils/pmsplash" &

# So it can be waited.
export PMSPLASH_PID=$!

kill_splash() {
    if kill -0 "$PMSPLASH_PID" >/dev/null 2>&1; then
        kill -9 "$PMSPLASH_PID"
    fi
}

trap kill_splash EXIT
