I love the smell of napalm in the morning, it smells like... Victory.
[edit: added note]
[edit 2: Change script to allow other programs to pass Args.]
Ok, here is what I had to do to get this thing working the way I wanted. I had to use two mozilla command line options to get this going.
In general form they are:
mozilla -remote "OpenURL(<url>, new-window)"
mozilla -remote ping
* note: Mozilla and MozillaFirebird handle the -remote "OpenU ... w)" command differently if <url> is left blank. Mozilla uses the homepage and FireBird leaves you in a blank screen.
The first opens a new window with the specificed URL and the second writes a message to std-err to notify the user if there is an existing open window. We need the latter because the -remote option just craps out if there isn't a browser window open to begin with.
To use the script, copy the text below into a file called /usr/local/bin/moz and make sure you modify the moz variable to point to your mozilla script.
You can then use the moz command in your launchers.
# Mozilla startup script
# I had issues with the way Mozilla spawned new windows. Fortunately,
# they gave us the ability to ping remote windows to see if any were open.
# They also let us spawn a new window from the existing session. yay.
# It's unfortunate that they didn't build this in automatically...
# Author: email@example.com
# Files : /usr/local/bin/moz
# Usage : moz &
# Point this to your REAL script that runs mozilla
isRunning=`2>&1 $moz -remote ping`
case $isRunning in
# Start a new mozilla session
"No running window found." )
# Spawn a new mozilla window from the existing session
"Failed to send command." )
$moz -remote "OpenURL ( "$*" , new-window)"
# Dude, something's wrong.
echo "This was the return value: $isRunning"