#!/bin/sh
#!/bin/ksh

# Read this rc from rc.local (or equiv.) without any argument, or, in
# interactive use, one tty device (/dev/tty?, or just /dev/tty if you
# are on console) can be specified as a first argment ${1}. In the latter
# case, fireupfloyd() is called with the ${1} imediately without
# LED flag cloning.
# Fri Jun 18 11:13:44 1999 s.n.

# PTHREAD version.
# Sat Jul 17 18:48:14 1999

# Order of fireupfloyd() and flag cloning is reversed.
# Now fireupfloyd() returns.
# Sat Jun 26 01:43:54 1999 s.n.

fireupfloyd () {
    dev=${1:-/dev/tty}
    /usr/local/bin/floyd -v ${dev} ${floydop1} ${floydop2} ${floydop3} \
		           > /tmp/floyd.Log 2>&1 &
}

floydop1="-C --"
floydop2="-ES --"
# Third one is run as non-thread:
floydop3="-pi ppp0 -N"
#floydop3="-pi ul0 -N"

# for interactive use
if [ ! -z "$@" ] ; then
    fireupfloyd "$@"
    exit $?
fi

if [ -x /usr/local/bin/floyd ]; then

    # Start ours anyway,
    # Better to choose a VC on which you do not launch xinit/startx,
    # or the floyd(s) might die on X shutdown (especially when xinit/startx
    # is `exec'ed)
    fireupfloyd /dev/tty0 

    # then clone LED flags all over the VCs with floyd.
    echo "Floyd(s) started."
    echo "Now setting up VCs for the floyd(s) in background"

    # Make all VCs blink
    (
      for i in /dev/tty[0-9]
      do
        /usr/local/bin/floyd $i &
        #/usr/local/bin/floyd < $i &     ### 2>/dev/null &
        sleep 1
        kill $!
#       echo -n "."
      done
#       echo  "Done."
    ) &
#  echo
fi

# If keyrepeat seems too slow, use kbdrate explicitly.
# kbdrate -r 30
