#!/bin/bash

TITLE='Mozilla Firefox'
case "$1" in

        stop) wmctrl -c "$TITLE"; exit 0 ;;
        sandbox) VAR='.sandbox' ;;
esac

cd /opt/euro-beta
./systools/start_firefox_browser "https://www$VAR.paypal.com/commercesetup/APICredentials"

exit 0



{

  FFOX_BIN=`which firefox`
  if [ -z "$FFOX_BIN" ]
  then
    apt update
    apt install firefox wmctrl -y
  fi


#  firefox https://www$VAR.paypal.com/commercesetup/APICredentials?guided=true &
#  firefox https://www$VAR.paypal.com/commercesetup/APICredentials &
  su euro3g -c "unset XDG_RUNTIME_DIR; firefox -UILocale it-IT -contentLocale IT --new-instance https://www$VAR.paypal.com/commercesetup/APICredentials" &

  FF=$!
  for ((i=0; i<20; i++))
  do
    sleep 0.1
    wmctrl -r "$TITLE" -t 2
    wmctrl -a "$TITLE"
  done
  wait $FF
  wmctrl -s 0 
} &

