Icons instead of taskbar possible?

Jack Coates jack at monkeynoodle.org
Sun Dec 21 19:32:13 CET 2003


On Sun, 2003-12-21 at 01:34, Merlyn Morgan-Graham wrote:
<snip... don't care>
> Now I'm off to figure out how to force new browser windows to open up a 
> new tab, and not a new window, in Firebird =)

Here's a nice script. Discovered recently that it even works across ssh
tunnels, opening links from my remote Evolution in the local Mozilla :-)

--
Jack at Monkeynoodle Dot Org: It's A Scientific Venture...
**********************************************************************
*"And it's lend me ten pounds, I'll buy you a drink, and mother wake *
*me early in the morning!"                                           *
*-- Boys From County Hell from Red Roses For Me by The Pogues        *
**********************************************************************
-------------- next part --------------
#! /usr/bin/env python

#
# Program: mozy
# Author:  Cliff Wells <clifford.wells at attbi.com>
# 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))


More information about the Xfce mailing list