#!/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_firebird
# Author: Mohammed Sameer <Uniball@linux-egypt.org>
# Script Version: 0.2
# Script Purpose: Check for a running firebird process and and open a new 
#		  tab with a given URL or execute firebird with that URL
# Usage: preferences->other->web browser-> "launch_firebird "%s""
############################################################################
# Version 0.2, June 2003, Paul Mangan <claws@thewildbeast.co.uk>
# Changes: renamed and edited to reflect the browser's name change from
# 'phoenix' to 'firebird'.
############################################################################

URL=$*
# name of binary (change it if necessary):
FIREBIRD=mozilla-firebird

firebird_running()
{
$FIREBIRD -remote "openurl($URL,new-tab)"
}
firebird_new()
{
$FIREBIRD $URL
}


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

