#!/bin/sh
#
# "hyaku"
#    Display Ogura-Hyakunin-Issyu on a terminal screen forever
#
# The following command may be usuful on X-Window 
# kterm -geometry 46x4 -T Hyakunin-Issyu -fk kanji24 -fr r24 -fn 12x24 -e hyaku
#

 
# read a configuration file 
. ${HYAKU_CONFIG:-/home/kakugawa/hack/HyakuninIssyu/conf}


# obtain sleep time
case $# in
0)
  ;;
*)
  case $1 in
  [0-9]*)
    if [ $1 -gt 0 ] ; then
      DISPLAY_PERIOD=$1;
    fi
    ;;
  *)
    echo "Usage: hyaku [SLEEP]"  >&2  
    exit 1
    ;;
  esac
  ;;
esac


# display loop
while true; do
  sed 's/#.*$//' ${POEM_FILE_PATH} \
    | grep -v '^[ 	]*$' \
    | (while read NUM AUTH S1 S2 S3 S4 S5; do
         read KNUM KAUTH KS1 KS2 KS3 KS4 KS5
         echo "$S1 $S2 $S3"
         echo "    $S4 $S5"
         echo "                    $AUTH"
         sleep ${DISPLAY_PERIOD}
       done )
done

#EOF
