#!/bin/sh
# Starts RetroArch. On the first start the phone defaults from plinius-games are written into the
# user's retroarch.cfg, after the skeleton from the retroarch package. Later starts leave the file
# alone, so every change made in RetroArch stays.
cfg="${XDG_CONFIG_HOME:-$HOME/.config}/retroarch/retroarch.cfg"
if [ ! -e "$cfg" ]; then
	mkdir -p "${cfg%/*}" "$HOME/Games/bios"
	if cat /etc/retroarch.cfg /usr/share/plinius-games/retroarch.cfg > "$cfg.new"; then
		mv "$cfg.new" "$cfg"
	else
		rm -f "$cfg.new"
	fi
fi
exec retroarch "$@"
