#! /bin/sh

# Script to run mozilla/Firebird/Firefox/whatever. Detects whether there's an instance running already; if so uses -remote
# Usage:   run_mozilla_script "/path/to/mozilla" "url_to_load"
# Adapted from several similar scripts found on the Mozilla site/fora
# PS This is the Firefox version.  Firefox 0.9(.1) requires the "-a firefox" after its pathname

		# The first parameter is the filepath of mozilla
mozpathname=$1
 
		# See if instance is running
if ! $mozpathname -a firefox -remote 'ping()' 2>/dev/null; then
		# It is not running, start a new instance
    $mozpathname "$2"
else
		# It is running, tell it to open the url in a new window
    $mozpathname -a firefox -remote "openurl($2,new-window)"
		# If you'd prefer to open in a new tab, replace the above line with:
    # $mozpathname -a firefox -remote "openurl($2,new-tab)"
fi

