distribution/packages/games/emulators/openbor/scripts/openbor.sh
2022-02-05 09:23:32 -05:00

44 lines
1.2 KiB
Bash
Executable file

#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2019-present Shanti Gilbert (https://github.com/shantigilbert)
# Copyright (C) 2021-present 351ELEC (https://github.com/351ELEC)
# OpenBOR only works with Pak files, if you have an extracted game you will need to create a pak first.
pakname=$(basename "$1")
pakname="${pakname%.*}"
CONFIGDIR="/storage/openbor"
PAKS="${CONFIGDIR}/Paks"
SAVES="${CONFIGDIR}/Saves"
# Make sure the folders exists
mkdir -p "${CONFIGDIR}"
mkdir -p "${PAKS}"
mkdir -p "${SAVES}"
# Check if master.cfg exists
if [ ! -f "${CONFIGDIR}/master.cfg" ]; then
cp -f "/usr/config/openbor/master.cfg" "${CONFIGDIR}/"
fi
# Clear PAKS folder to avoid getting the launcher on next run
rm -rf ${PAKS}/*
# make a symlink to the pak
ln -sf "$1" "${PAKS}"
# only create symlink to master.cfg if its the first time running the pak
if [ ! -f "${SAVES}/${pakname}.cfg" ]; then
ln -sf "${CONFIGDIR}/master.cfg" "${SAVES}/${pakname}.cfg"
fi
# We start the fake keyboard
gptokeyb openbor &
# Run OpenBOR in the config folder
cd "${CONFIGDIR}"
LD_PRELOAD=/usr/lib/libSDL2-2.0.so.0.14.0 SDL_AUDIODRIVER=alsa OpenBOR
# We stop the fake keyboard
killall gptokeyb &