Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 2a529f534c
Fetching contributors…

Cannot retrieve contributors at this time

executable file 149 lines (139 sloc) 4.866 kb
#!/bin/sh
# vim:set et sw=2:
# As the name suggests, picks a sensible web browser based on what's installed
# and what environment we're in. The -T option forces a terminal browser, -G
# a gui browser, and -dump a formatted dump of the website.
[ "$PATH" ] || PATH="$HOME/bin:/usr/local/bin:/usr/bin/X11:/usr/bin:/bin"
ulimit -u 384 >/dev/null 2>/dev/null
[ -f "$HOME/.sb.local" ] && . "$HOME/.sb.local"
if [ "$1" = "-T" ]; then
shift
terminal=' '
fi
content_type() {
curl -I "$1" 2>/dev/null|grep '^Content-[Tt]ype:'|sed -e 's/^Content-[Tt]ype: *//' -e 's/;.*//'
}
if [ "$1" = "-dump" ]; then
shift
terminal='-dump'
launch() { exec "$@" -dump
}
elif [ "$1" = "-G" ]; then
shift
launch() { nohup x-terminal-emulator -title 'WWW-Browser' -e "$@" >/dev/null 2>&1 & exit 0
}
elif [ "$STY" ]; then
launch() { screen -ln -fn -t "WWW" "$@"; sleep 2; exit 0
}
elif [ ! -t 1 ]; then
launch() { nohup x-terminal-emulator -title 'WWW-Browser' -e "$@" >/dev/null 2>/dev/null & exit 0
}
else
launch() { exec "$@"
}
fi
fvwm_find_browser() {
if [ -x "`which FvwmCommand 2>/dev/null`" -a -n "$FVWM_USERDIR" ]; then
FvwmCommand FuncFindWebBrowser
fi
return 0
}
if [ -x /usr/bin/cygstart -a -z "$terminal" ]; then
exec cygstart "$*"
elif [ -n "$SECURITYSESSIONID" -o -n "$Apple_PubSub_Socket_Render" ] && [ -x /usr/bin/open -a -z "$terminal" ]; then
exec open "$*"
elif [ "$DISPLAY" -a -z "$terminal" ]; then
url="$*"
case "$DISPLAY" in
:*|localhost*:0*|127.0.0.1:*|`hostname`*:0*) gui=: ;;
esac
if [ -e "$url" ]; then
case "$url" in
/*) url="file://$url" ;;
*) url="file://`pwd`/$url" ;;
esac
else
case "$url" in www*) url="http://$url"; esac
fi
case "$gui$url" in
file:*|/*) ;;
:spotify:*) exec spotify "$url" ;;
*:*|www*|'')
for browser in firefox mozilla-firebird mozilla netscape; do
if [ -x "`which $browser 2>/dev/null`" ] && \
xlsclients | grep $browser >/dev/null; then
nice -n 1 $browser -remote "openURL($url,new-tab)" >/dev/null 2>/dev/null && fvwm_find_browser && exit 0
fi
done
if [ -x "`which google-chrome 2>/dev/null`" ] && \
pidof google-chrome >/dev/null; then
nice -n 1 google-chrome "$url" >/dev/null 2>/dev/null && fvwm_find_browser && exit 0
fi
if [ -x "`which chromium-browser 2>/dev/null`" ] && \
pidof chromium-browser >/dev/null; then
nice -n 1 chromium-browser "$url" >/dev/null 2>/dev/null && fvwm_find_browser && exit 0
fi
if [ -x "`which opera 2>/dev/null`" ] && \
pidof opera >/dev/null; then
nice -n 1 opera -remote "openURL($url,new-page)" >/dev/null 2>/dev/null && fvwm_find_browser && exit 0
fi
if [ -x "`which galeon 2>/dev/null`" ] && \
xlsclients | grep galeon >/dev/null; then
nice -n 1 galeon -n "$url" >/dev/null 2>/dev/null && fvwm_find_browser && exit 0
fi
if [ -x "`which dcop 2>/dev/null`" ]; then
konq="`dcop 2>/dev/null|grep konqueror|head -1`"
if [ "$konq" ]; then
dcop "$konq" 'konqueror-mainwindow#1' newTab "$1" && fvwm_find_browser && exit 0
fi
fi
[ "$gui" ] && \
for browser in $XBROWSERS google-chrome chromium-browser firefox mozilla-firebird mozilla konqueror opera netscape galeon dillo; do
if [ -x "`which $browser 2>/dev/null`" ]; then
case $browser in
mozilla) dir="$HOME/.mozilla/default" ;;
firefox) dir="$HOME/.mozilla/firefox" ;;
mozilla-firebird) dir="$HOME/.phoenix/default" ;;
esac
[ -d "$dir" ] || new=1
nohup nice -n 1 $browser "$@" >/dev/null 2>/dev/null &
disown >/dev/null 2>&1
sleep 5
if [ "$new" -a -d "$dir" ]; then
if killall $browser-bin 2>/dev/null; then
echo 'Performing an initial "tpope install"'
sleep 5
find "$dir" \( -name "localstore.rdf" -o -name "bookmarks.html" \) -exec rm {} \;
tpope install
echo 'Restarting browser so changes will take effect'
nohup nice -n 1 $browser "$@" >/dev/null 2>/dev/null &
disown >/dev/null 2>&1
sleep 5
else
echo 'Performing an initial "tpope install"'
tpope install
fi
fi
sleep 5
exit 0
fi
done ;;
esac
fi
if [ "$terminal" = "-dump" -a -x "`which lynx 2>/dev/null`" ]; then
launch lynx -force_html "$@"
elif [ -x "`which w3m 2>/dev/null`" ]; then
if [ "$*" ]; then
launch w3m -T text/html "$@"
else
launch w3m http://www.google.com/
fi
elif [ -x "`which elinks 2>/dev/null`" ]; then
launch elinks "$@"
elif [ -x "`which links 2>/dev/null`" ]; then
launch links "$@"
elif [ -x "`which lynx 2>/dev/null`" ]; then
launch lynx -force_html "$@"
fi
echo "No web browsers found." >&2
exit 1
Jump to Line
Something went wrong with that request. Please try again.