#! /bin/sh
#
# Description: Shell script to start "links" binary.
#
# Configure:
#        1. Edit the variable entries below this section.
#           (See "install", below, about binary name.)
#        2. Change the xterm options to suit your x-terminal and setup.
#        
# Install:
#        1. Rename your Links binary to "links-0.82" or equivalent.
#        2. Copy this script to somewhere in your $PATH, like
#           "/usr/local/bin/links".
#        3. Make sure that it is executable.
#
# Run:
#        1. Simply invoke as "links", with or without file arguments.
#
# Note: 
# This version will NOT permit or handle any of Links's command line options.
#
# Want it to do something else? Do it yourself ;-)

# Assign some variables
BIN=/usr/local/bin/links-0.82
HOMEDOC=$HOME/.links/startpage.html  # make sure you put a file there ;-)
# HOMEDOC="http://linuxtoday.com"
x_term="xterm"
console="linux"


# Change to the Home directory. Links gets confused if it is anywhere else.
cd $HOME;


# See if there are any filename options and handle them. Uses same
# auto-prefixing as the Links binary.

case "$1" in
   http:*|ftp:*|file:*)
        url=$1
    ;;

     ftp*)
        url=ftp://$1  
      ;;
		  
    ./*|~/*|/*|../*)
      url=file://$1 
       ;;
		      
    *.*)
        url=http://$1
    ;;

   *)
	url=$HOMEDOC
    ;;

  esac

# Depending upon the current environment, Links starts or fails.
if
   [ $TERM == "linux" ]		# Change "linux" to _your_ console term.
then
  $BIN $url
elif
   [ $TERM == "xterm-debian" ]  # Change "xterm-debian" to your x-term.
then
	$x_term \
   	 -title "Links: The WWW Text Browser."\
         -fn "6x13"\
         -geometry "132x37"\
         -n "Links"\
	 -e $BIN $url &

else
   echo
   "Links startup script failed at TERM setting. Please edit the
   console and/or x-term entries."
fi

exit 1
