SHA256
1
0
forked from pool/xfig
xfig/browser

79 lines
1.3 KiB
Bash

#!/bin/bash
#
# browser script
#
# Copyright (c) 2004 SuSE Linux AG, Nuernberg, Germany.
# Copyright (c) 2004 Werner Fink
#
# Author: Werner Fink
prog=""
for p in \
Mozilla \
mozilla \
Netscape \
netscape \
Mosaic \
mosaic \
opera \
konqueror \
amaya
do
prog=$(type -p $p) && break
done
test -n "$prog" || { echo "${0##*/}: no web browser found" 1>&2; exit 1; }
cmd="openBrowser"
open="openURL"
for opt in $@ ; do
case "$opt" in
http://*|https://*|www.*)
url=$opt
;;
file:/*|*/*.htm|*/*.html)
url=$opt
open="openFile"
;;
ftp://*|*/*.htmls)
url=$opt
;;
*.htm|*.html|*.htmls)
url=$PWD/$opt
;;
-discussions|-news)
cmd=openNewsgroups
;;
-messenger|-mail)
cmd=openInbox
;;
-composer|-edit)
cmd=composeMessage
;;
-component-bar)
cmd=toggleTaskbar
;;
-remote|-help)
cmd=""; url="";
break
;;
esac
done
case "$prog" in
*/[nN]etscape|*/[Mm]ozilla)
ret=0
if test -n "$url" ; then
$prog -noraise -remote "xfeDoCommand(openBrowser)" &> /dev/null && \
$prog -remote "$open($url)"
ret=$?
elif test -n "$cmd" ; then
$p -noraise -remote "xfeDoCommand($cmd)" &> /dev/null
ret=$?
fi
test $ret -eq 0 && exit 0
esac
# You are at your own
exec -a $prog $prog ${1+"$@"}