#!/bin/sh
# Dwarf Fortress wrapper for Void Linux
DF_DIR="/opt/dwarffortress"
DIRECTORY="${XDG_DATA_HOME:-$HOME/.local/share}/dwarffortress"

if [ ! -d "$DIRECTORY" ]; then
	echo "Setting up $DIRECTORY"
	mkdir -p "$DIRECTORY"
	ln -s "$DF_DIR/data" "$DIRECTORY/data"
	ln -s "$DF_DIR"/*.so* "$DIRECTORY/" 2>/dev/null
fi

cd "$DIRECTORY" || exit 1
LD_LIBRARY_PATH="${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$DF_DIR" exec "$DF_DIR/dwarfort" "$@"
