3 # Invoke whatever HTML viewer is installed...
5 # htmlview [--remote|--local] URL
6 # --remote: We need support for remote (http/ftp) URLs
7 # --local: This is a local (doc) html file
8 # If neither --remote nor --local is given, it will
9 # be determined automatically.
11 # List the tools in order of preference.
13 # written by Bernhard Rosenkraenzer <bero@redhat.com>
14 # (c) 2000-2001 Red Hat, Inc.
16 # made insensitive on file extension and piped stdout detection
17 # by Andrzej M. Krzysztofowicz <ankry@pld-linux.org>
19 # This script is in the public domain.
21 if [ "$1" == "--remote" ]; then
24 elif [ "$1" == "--local" ]; then
28 if echo $1 |egrep -q "^(http://|ftp://|www\.|ftp\.)" 2>/dev/null; then
34 if ls -l /proc/self/fd/1 | grep 'pipe:' >/dev/null 2>&1; then
42 if [ "$1" = --name ] ; then
44 elif [ "$1" = --dumpcmd ]; then
46 echo -n /usr/bin/elinks -dump $*
47 if [ $STDOUT_IS_PIPE = 0 ]; then
48 echo \| ${PAGER:-/bin/more}
53 if [ $STDOUT_IS_PIPE = 0 ]; then
54 /usr/bin/elinks -dump $* | ${PAGER:-/bin/more}
56 /usr/bin/elinks -dump $*
62 if [ "$1" = --name ] ; then
64 elif [ "$1" = --dumpcmd ]; then
66 echo -n /usr/bin/links -dump $*
67 if [ $STDOUT_IS_PIPE = 0 ]; then
68 echo \| ${PAGER:-/bin/more}
73 if [ $STDOUT_IS_PIPE = 0 ]; then
74 /usr/bin/links -dump $* | ${PAGER:-/bin/more}
76 /usr/bin/links -dump $*
82 if [ "$1" = --name ]; then
84 elif [ "$1" = --dumpcmd ]; then
86 echo /usr/bin/lynx --force-html $*
87 elif [ $STDOUT_IS_PIPE = 0 ]; then
88 /usr/bin/lynx --force-html $*
90 /usr/bin/lynx --force-html -dump $*
95 if [ "$1" = --name ] ; then
97 elif [ "$1" = --dumpcmd ]; then
99 echo /usr/bin/w3m -T text/html $*
101 /usr/bin/w3m -T text/html $*
106 if declare -F | sed "s/^declare -f //" | grep "^$1\$" >/dev/null ;
115 IS_FUNC "$1" && test -x `$1 --name`
118 TERMS_KDE="/usr/bin/konsole /usr/bin/kvt"
119 TERMS_GNOME="/usr/bin/gnome-terminal"
120 TERMS_GENERIC="/usr/bin/rxvt /usr/X11R6/bin/xterm /usr/bin/Eterm"
121 if [ $REMOTE == 1 ]; then
122 TTYTOOLS="/usr/bin/elinks /usr/bin/links /usr/bin/lynx /usr/bin/w3m"
123 X11TOOLS_KDE="/usr/bin/konqueror /usr/bin/kfmbrowser"
124 X11TOOLS_GNOME="/usr/bin/galeon /usr/bin/mozilla"
125 X11TOOLS_GENERIC="/usr/bin/mozilla /usr/bin/netscape"
127 TTYTOOLS="ELINKS_CMD LINKS_CMD LYNX_CMD W3M_CMD /usr/bin/less /bin/more /bin/cat"
128 X11TOOLS_KDE="/usr/bin/khelpcenter /usr/bin/konqueror /usr/bin/khcclient /usr/bin/kdehelp /usr/bin/kfmbrowser"
129 X11TOOLS_GNOME="/usr/bin/gnome-help-browser"
130 X11TOOLS_GENERIC="/usr/bin/mozilla /usr/bin/netscape"
133 if [ "x`/sbin/pidof gnome-session`" != "x" ]; then
134 X11TOOLS="$X11TOOLS_GNOME $X11TOOLS_KDE $X11TOOLS_GENERIC"
135 TERMS="$TERMS_GNOME $TERMS_KDE $TERMS_GENERIC"
137 X11TOOLS="$X11TOOLS_KDE $X11TOOLS_GNOME $X11TOOLS_GENERIC"
138 TERMS="$TERMS_KDE $TERMS_GNOME $TERMS_GENERIC"
141 if test "x$DISPLAY" = x; then
142 for i in $TTYTOOLS; do
143 if IS_FUNC_WORKING $i; then
151 for i in $X11TOOLS; do
152 [ -x $i ] && exec $i $*
160 for i in $TTYTOOLS; do
161 if IS_FUNC_WORKING $i; then
162 exec $CONSOLE `$i --dumpcmd $*`