#!/bin/bash
# Rescapp Web run script
# Copyright (C) 2012,2013,2014,2015,2016,2017,2018,2019,2020 Adrian Gibanel Lopez
#
# Rescapp is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Rescapp is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Rescapp.  If not, see <http://www.gnu.org/licenses/>.

source ${RESCAPP_LIB_FILE}

FIREFOX_OK_STR="Web browser was successfully started in the background."
FIREFOX_KO_STR="Rescapp was unable to start Web browser, is it installed?"

# Top left corner
WIDTH=600
HEIGHT=460
GRAVITY=0

X_POSITION=0
Y_POSITION=0

FIREFOX_FULL_PATH="$(which ${FIREFOX_COMMAND})"
if [ -x "${FIREFOX_FULL_PATH}" ] ; then
  "${FIREFOX_FULL_PATH}" ${RESCATUX_URL} &
  sleep 5s;

  wmctrl \
    -r ${FIREFOX_WINDOW_STR} \
    -e ${GRAVITY},\
${X_POSITION},\
${Y_POSITION},\
${WIDTH},\
${HEIGHT}
  rtux_Message_Success ${FIREFOX_OK_STR}
else
  rtux_Message_Failure ${FIREFOX_KO_STR}
fi
