#!/usr/bin/bash
 . /etc/blackPanther-default-apps.conf
#*********************************************************************************************************
#*   __     __               __     ______                __   __                      _______ _______   *
#*  |  |--.|  |.---.-..----.|  |--.|   __ \.---.-..-----.|  |_|  |--..-----..----.    |       |     __|  *
#*  |  _  ||  ||  _  ||  __||    < |    __/|  _  ||     ||   _|     ||  -__||   _|    |   -   |__     |  *
#*  |_____||__||___._||____||__|__||___|   |___._||__|__||____|__|__||_____||__|      |_______|_______|  *
#* http://www.blackpantheros.eu | http://www.blackpanther.hu - kbarcza[]blackpanther.hu * Charles Barcza *
#*************************************************************************************(c)2002-2024********

echo -e "${YEL} PhotoGimp started on $(lsb_release -sir)...$DEF"

HERE=`dirname "$(readlink -f "${0}")"`
datadir=/usr/share
bindir=/usr/bin

msg() {

	MSG="$1"
	if [ -n "$DISPLAY"  ];then
	    bubblemsg error "$MSG"
	else
	    echo "$MSG"
	fi


}

if [ -x "$datadir/photogimp/gimp" ] && [ ! -n "$(readlink $datadir/photogimp/gimp)" ];then
    diff $bindir/gimp $datadir/photogimp/gimp >/dev/null || PHOTOGIMP=YES
    if [ "$PHOTOGIMP" = "YES" ];then
    msg "PhotoGIMP Found! Requires Apply new binary.. Reinstall PhotoGimp!"
    fi
elif  [ -d "$datadir/photogimp" ];then
    msg "PhotoGIMP directory found but missing binary. Please reinstall PhotoGimp!"
fi


if [ -z ${XDG_CONFIG_HOME} ]; then
  export GIMP3_DIRECTORY="$HOME/.config/PhotoGIMP/";
else
  export GIMP3_DIRECTORY="$XDG_CONFIG_HOME/PhotoGIMP/";
fi

if [ ! -f "$GIMP3_DIRECTORY/firstrun" ]; then
  mkdir -p "$GIMP3_DIRECTORY/gradients";
  cp -rf "$HERE/content"/* "$GIMP3_DIRECTORY";
  echo > "$GIMP3_DIRECTORY/firstrun"
fi

$HERE/gimp $@ 2>/dev/null
