#!/bin/sh
#
# Sample URL handles script for xpdf.urlCommand.  It assumes that
# Netscape will be around.  You can instead launch a terminal with
# lynx inside - for example
#

# Michal Jaegermann, <michal@harddata.com>, 2001/Jan/01

# Try first to hook up to a running Netscape instance and open new
# Netscape window.  If Netscape is not around then try lynx and links first

[ "$1" ] || exit 0

LYNX=/usr/bin/lynx
NETS=/usr/bin/netscape

if ! [ -x $NETS ] ; then
    [ -x $LYNX ] || LYNX=/usr/bin/links
    if ! [ -x $LYNX ] ; then
       xterm -e sh -c "echo Edit $0 to include your URL handler; echo $1; read"
       exit 0
    fi
    xterm -e $LYNX "$1" &
    exit 0
fi 

if ! $NETS -remote "openURL($1)" > /dev/null 2>&1 ; then
    $NETS "$1" &
fi

exit $?
