On Wed, 2003-11-12 at 07:36, Michael Holt wrote:
> Hey,
> I just started using evolution and I've found that when I click on a
> link from my email, it tries to start a new session of mozilla.  When
> this happens, mozilla complains about having a session already open. 
> How do I make it look to see if an instance is already open?  I imagine
> that this is probably more to do with how mozilla gets called to begin
> with, so; I used gnome control center to change the default handler to
> mozillafirebird %s -- I thought the %s was what was supposed to take
> care of my problem?
> 
> tia

use this attached script as your default browser instead -- it opens new
tabs if there's already a browser open, or opens a new browser if
necessary. Set up for Mozilla now, but making it work with Firebird or
whatever would be fairly simple from the examples. Thanks to Ciff Wells,
who wrote it.
-- 
Jack Coates
Monkeynoodle: A Scientific Venture...
#! /usr/bin/env python

#
# Program: mozy
# Author:  Cliff Wells <[EMAIL PROTECTED]>
# Version: 0.4
#
# Does what gnome-moz-remote ought to: if a browser window is open,
# opens url in a new tab. If no browser is open, opens one.
#
# Usage: mozy [--browser browser] [--url] <url>
#        mozy --help
# Examples: mozy "http://www.google.com";
#           mozy --browser opera "http://www.google.com";
#           mozy --browser mozilla --url "http://www.google.com";
#   Note that the first argument that doesn't start with -- terminates
#   further processing of arguments.
#
# Bugs:
#  - Konqueror doesn't support remote commands or tabbed browsing, aka NOTABUG.
#


# ========================== user configuration ===============================

# General options
browser = 'mozilla' # one of mozilla, opera, konqueror

# Opera options
usejava = 1       # enable Java
java = 'java'     # Java binary name
forceSDIMode = 1  # make it more like Mozilla's tabbed browsing

# ========================= end user configuration ============================

import sys, os

usejava = usejava and os.system("which %s > /dev/null" % java) == 0

browserOptions = {
    'mozilla':   '-remote "openURL("%s", new-tab)"',
    'opera':     '-remote "openURL("%%s", new-page)" %s' % ['', '-windowmode 
sdi'][forceSDIMode],
    'konqueror': '--profile webbrowsing "%s"', # no remote commands? no tabbed 
browsing? pfft.
    }

# -----------------------------------------------------------------------------
def getopts(argv):
    "returns arguments as dictionary {'arg': [arglist]}"
    validOpts = { # { 'opt': argument count }
        'browser': 1,
        'help':    0,
        'url':     1,
        }
    suppliedOpts = {}
    nextIsArg = 0
    for arg in argv[1:]:
        if nextIsArg:
            suppliedOpts[opt].append(arg)
            nextIsArg -= 1
        else:
            if arg[:2] == '--':
                opt = arg[2:]
                if opt in validOpts:
                    suppliedOpts[opt] = []
                    nextIsArg = validOpts[opt]
                else:
                    suppliedOpts['help'] = [] # force a help message
            else:
                suppliedOpts['url'] = [arg]
                break
            
    return suppliedOpts

# -----------------------------------------------------------------------------
def help():
    print "\nUsage: mozy [--browser <mozilla|opera|konqueror>] [--url] <url>"
    print "       mozy --help\n\n"

# =============================================================================

options = getopts(sys.argv)

if 'help' in options:
    help()
    raise SystemExit

if 'browser' in options:
    if options['browser'][0] in browserOptions:
        browser = options['browser'][0]

if 'url' in options:
    url = options['url'][0]
else:
    url = 'about:blank'
    
if browser == 'opera' and usejava:
    os.putenv("OPERA_FORCE_JAVA_ENABLED", '1')
    # print "Java%senabled" % (' not ', ' ')[usejava]

if os.fork():
    raise SystemExit
else:
    if os.system('%s %s' % (browser, browserOptions[browser] % url)):
        os.system('%s "%s"' % (browser, url))
Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com

Reply via email to