#!/bin/bash

# Copyright  2002 Mohammed Sameer <Uniball@linux-egypt.org> 
#
# This file 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 2 of the License, or
# (at your option) any later version.
# 
# This program 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 this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
############################################################################
# Script Name: launch_phoenix
# Author: Mohammed Sameer <Uniball@linux-egypt.org>
# Script Version: 0.1
# Script Purpose: Check for a running phoenix process and and open a new tab 
#                 with a given URL or execute phoenix with that URL
# Usage: preferences->other->web browser-> "launch_phoenix "%s""
############################################################################

URL=$*

phoenix_running()
{
phoenix -remote "openurl($URL,new-tab)"
}
phoenix_new()
{
phoenix $URL
}


STR=`phoenix -remote "ping()" 2>&1 | grep No`
#echo $STR
if [[ "$STR" == "No running window found." ]]; then
phoenix_new;
else
phoenix_running;
fi

