Re: [Evolution] preferred web browser



Paul Hands wrote:

#!/bin/bash

#Try to launch a new window on an existing browser process.
#If it fails, return code will be non-zero, and we will need to start
a new one.
/opt/MozillaFirebird/MozillaFirebird -remote "openurl($arg,
new-window)"
#
#Now check the return code.
#If non zero, spawn a new mozilla process.

if [ $? -ne 0 ]; then
    echo "No existing Firebird - start a new one on site $arg"
    /opt/MozillaFirebird/MozillaFirebird $arg > /dev/null 2>&1 &
fi


Another approach (you can really solve all the world's problems with
Perl... :-) similar to Paul's

#!/usr/bin/perl
use strict;
my $url = $ARGV[0];
`/opt/Firebird/MozillaFirebird -remote "ping()"`;
# $? = false if running, true if not
if ($?) {
        exec "/opt/Firebird/MozillaFirebird $url";
} else {
        exec "/opt/Firebird/MozillaFirebird -remote 'openURL($url,
new-tab)'";
}

Only suggestion I would make regarding Paul's bash solution is to use
the "ping()" test rather than just attempting to contact a possibly
nonruning Firebird, since that is what it is for. However I did not test
to see which is quicker to determine the nonexistance of a running
process.

You can learn more about the "-remote" option at:

http://www.mozilla.org/unix/remote.html

Only issue I have is with window focus. Often the Firebird window ends
up getting popped to the top and getting focus. Any ideas on how to
prevent this would be appreciated.

cheers,
brad

-- 
Brad Warkentin
Email: <brad warkentin rogers com





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]