[arch] /usr/bin/mozilla

Matt Niswonger arch@archlinux.org
Wed, 04 Feb 2004 17:14:30 -0600


This is a multi-part message in MIME format.
--------------080706040108020502010208
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

I'm assuming the reason for this script is to fix the profile headache 
with Mozilla.  Why does lauching this script not only open a new tab in 
the current window, but also try to spawn another window?  The 
attachment is a diff I came across that fixes the profile problem, 
however it is dated.  I've been using it since 1.4 was in beta.  It 
still seems to work with 1.6, but I'm curious if anyone knows of a more 
recent/better fix.  Thanks.

--------------080706040108020502010208
Content-Type: text/plain;
 name="mozilla.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="mozilla.diff"

--- run-mozilla.sh	6 Nov 2002 22:22:32 -0000	1.44
+++ run-mozilla.sh	13 Dec 2002 04:56:04 -0000
@@ -65,10 +65,11 @@
 #
 cmdname=`basename "$0"`
 MOZ_DIST_BIN=`dirname "$0"`
-MOZ_DEFAULT_NAME="./${cmdname}-bin"
-MOZ_APPRUNNER_NAME="./mozilla-bin"
-MOZ_VIEWER_NAME="./viewer"
+MOZ_DEFAULT_NAME="${MOZ_DIST_BIN}/${cmdname}-bin"
+MOZ_APPRUNNER_NAME="${MOZ_DIST_BIN}/mozilla-bin"
+MOZ_VIEWER_NAME="${MOZ_DIST_BIN}/viewer"
 MOZ_PROGRAM=""
+MOZ_CLIENT_PROGRAM="${MOZ_DIST_BIN}/mozilla-xremote-client"
 
 exitcode=0
 #
@@ -131,6 +132,18 @@
 	return 0
 }
 ##########################################################################
+check_running() {
+    $MOZ_CLIENT_PROGRAM 'ping()'
+    RETURN_VAL=$?
+    if [ "$RETURN_VAL" -eq "2" ]; then
+      echo 0
+      return 0
+    else
+      echo 1
+      return 1
+    fi
+}
+##########################################################################
 moz_get_debugger()
 {
 	debuggers="ddd gdb dbx bdb"
@@ -448,9 +461,45 @@
 
 if [ $moz_debug -eq 1 ]
 then
-	moz_debug_program ${1+"$@"}
-else
-	moz_run_program ${1+"$@"}
+  moz_debug_program ${1+"$@"}
+  exit $exitcode
+fi
+
+USE_EXIST=0
+if [ "`check_running`" -eq "1" ] && [ $# -lt 2 ]; then
+  opt="$1"
+  case "$opt" in
+    -mail)
+      exec $MOZ_CLIENT_PROGRAM 'xfeDoCommand(openInbox)'
+      ;;
+    -compose)
+      exec $MOZ_CLIENT_PROGRAM 'xfeDoCommand(composeMessage)'
+      ;;
+    -*) ;;
+    *) USE_EXIST=1 ;;
+  esac
+fi
+if [ "${USE_EXIST}" -eq "0" ]; then
+  moz_run_program ${1+"$@"}
+  exit $exitcode
 fi
 
-exit $exitcode
+# If there is no command line argument at all then try to open a new
+# window in an already running instance.
+if [ -z "$1" ]; then
+  exec $MOZ_CLIENT_PROGRAM "xfeDoCommand(openBrowser)"
+fi
+
+# check to make sure that the command contains at least a :/ in it.
+echo $opt | grep -e ':/' 2>/dev/null > /dev/null
+RETURN_VAL=$?
+if [ "$RETURN_VAL" -eq "1" ]; then
+  # if it doesn't begin with a '/' and it exists when the pwd is
+  # prepended to it then append the full path
+  echo $opt | grep -e '^/' 2>/dev/null > /dev/null
+  RETURN_VAL=$?
+  if [ "${RETURN_VAL}" -ne "0" ] && [ -e `pwd`/$opt ]; then
+    opt="`pwd`/$opt"
+  fi
+fi
+exec $MOZ_CLIENT_PROGRAM "openurl($opt,new-window)"


--------------080706040108020502010208--