#!/bin/bash

export GDK_PIXBUF_MODULEDIR=$(pkg-config --variable=gdk_pixbuf_moduledir gdk-pixbuf-2.0)
export GDK_PIXBUF_MODULE_FILE=$(pkg-config --variable=gdk_pixbuf_cache_file gdk-pixbuf-2.0)
	
mkdir -p $HOME/.local/share/icons/hicolor/scalable/apps && cp $APPDIR/yuzu.svg $HOME/.local/share/icons/hicolor/scalable/apps

GITURL='https://api.github.com/repos/pineappleEA/pineapple-src/releases/latest'
GITVER=`( wget -qO- $GITURL 2>/dev/null || curl -sL $GITURL ) | grep "EA-" | grep -o 'EA-[[:digit:]]*'`
APPVER=`cat $APPDIR/version.txt`

if [[ -z "$GITVER" ]]; then
	$APPDIR/AppRun-patched "$@"
elif [ "$GITVER" = "$APPVER" ]; then
	$APPDIR/AppRun-patched "$@"
else
	$APPDIR/update.sh "$@"
fi