#
# setsoft:
#   Configure Automatic Report Text "Soft Copy"
#   feature of "llp" command
#
#   Written by Leor Zolman, 12/92
#
# Allows configuration of user's Soft-copy system if and only if
# the SOFTCOPY environment variable is set to Y.
#

SOFTDIR=$HOME/.Soft             # Soft-Copy configuration directory
SOFTSTAT=$SOFTDIR/Soft.status   # file containing Soft-Copy status
SOFTFILE=$SOFTDIR/Soft.file     # file naming Soft-Copy collection file

if [ "$SOFTCOPY" != Y ]; then
    echo "Your SOFTCOPY environment variable is not set to Y."
    echo "Therefore, Soft-copy features are not available."
    exit 0
fi

if [ ! -d $SOFTDIR ]; then
    mkdir $SOFTDIR
    touch $SOFTSTAT
    echo "$HOME/soft.out" > $SOFTFILE
    echo "The Soft-Copy master directory $SOFTDIR has been created."
    echo "Press Return to configure your Soft-Copy status. . .\c"
    read dummy
fi

read softstat < $SOFTSTAT
read softfile < $SOFTFILE

getfile()
{
    echo "Set collection file to [$softfile]: \c"
    read newfile
    [ "$newfile" != "" ] && softfile=$newfile
}

while true
do
    clear
    case "$softstat" in
        "") echo "Soft Copy status is: OFF.";;
        F)  echo "Soft Copy status is: File output ONLY";;
        B)  echo "Soft Copy status is: Both File and Printer output";;
    esac

    echo "Collection file name is: $softfile"

    echo
    echo Options:

    if [ "$softstat" != "" ]; then
        echo    "        0: Turn OFF soft copies"
    fi

    echo    "        1: Set Soft Copies to File ONLY"
    echo    "        2: Set Soft Copies to BOTH File and Printer output"
    echo    "        3: Change collection file"
    echo    "        4: Exit"
    echo

    echo "Your choice? \c"
    read command

    case "$command" in 

        ""|4) break 2;;

        0)  if [ "$softstat" != "" ]; then
                unset softstat
                echo "Soft copy facility has been turned OFF."
                sleep 1
            else
                echo "Soft copy facility is already off."   
                sleep 1
            fi;;

        1)  softstat=F
            getfile;;

        2)  softstat=B
            getfile;;

        3)  getfile;;
    esac
done

echo "$softstat\c" > $SOFTSTAT
echo "$softfile\c" > $SOFTFILE
exit 0
