SHA256
1
0
forked from pool/xfig
xfig/browser

92 lines
1.6 KiB
Bash

#!/bin/bash
#
# browser script
#
# Copyright (c) 2004 SuSE Linux AG, Nuernberg, Germany.
# Copyright (c) 2007 SuSE LINUX Products GmbH, Nuernberg, Germany
# Copyright (c) 2004, 2007 Werner Fink
#
# Author: Werner Fink
prog=""
for p in \
firefox \
Mozilla \
mozilla \
konqueror \
opera \
amaya \
Netscape \
netscape \
Mosaic \
mosaic
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
;;
firefox)
ret=0
if test -n "$url" ; then
$prog -remote "$open($url,new-window)"
ret=$?
elif test -n "$cmd" ; then
echo "${prog##*/} does not support $cmd"
exit 1
fi
test $ret -eq 0 && exit 0
esac
# You are at your own
exec -a $prog $prog ${1+"$@"}