#! /usr/bin/env bash

# make sure errors in sourced scripts will cause this script to stop
set -e

RUNTIME=$(readlink -f $(dirname "$0"))

export LD_LIBRARY_PATH=$RUNTIME/usr/lib:$LD_LIBRARY_PATH
export GST_PLUGIN_SYSTEM_PATH=$RUNTIME/usr/lib/gstreamer-1.0
export GST_PLUGIN_SCANNER=$RUNTIME/usr/lib/gstreamer1.0/gstreamer-1.0/gst-plugin-scanner
export SAYONARA_SHARE_DIR=$RUNTIME/usr/share/sayonara
export XDG_DATA_DIRS=$RUNTIME/usr/share:$XDG_DATA_DIRS
export GIO_MODULE_DIR=$RUNTIME/usr/lib/gio/modules

case "${XDG_CURRENT_DESKTOP}" in
    *GNOME*|*gnome*|*XFCE*)
        export QT_QPA_PLATFORMTHEME=gtk2
        ;;
*)
	export QT_QPA_PLATFORMTHEME=xcb
	;;
esac

exec "$RUNTIME"/usr/bin/sayonara "$@"

