#! /bin/sh
#
# Author: A. Wagner - A very simple approach without bells and whizzles
#
# Based upon:  Christoph Thiel <ct@kki.org>
#
### BEGIN INIT INFO
# Provides:          FOO
# Required-Start:    $syslog $remote_fs
# Required-Stop:     $syslog $remote_fs
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Short-Description: tp-scroll providing scrolling with IBM's Trackpoint
# Description:       see README for detailed description
### END INIT INFO


# Check for missing binaries (stale symlinks should not happen)
TPSCROLL_BIN=/usr/sbin/tp-scroll
test -x $TPSCROLL_BIN || exit 5

#
# Check for existence of needed config file and read it
#
TPSCROLL_CONFIG=/etc/sysconfig/tp-scroll
test -r $TPSCROLL_CONFIG || exit 6
. $TPSCROLL_CONFIG

TPSCROLL_ARGS="$TPSCROLL_BIN -i $INPUT_DEVICE -o $OUTPUT_DEVICE -x $XY_ACCEL_EXP -z $Z_ACCEL_EXP -m $Z_ACCEL_MULT"

case "$1" in
    start)
	echo -n "Starting tp-scroll "
	exec $TPSCROLL_ARGS &
	;;
    stop)
	echo -n "Shutting down tp-scroll "
	killall -TERM $TPSCROLL_BIN
	;;
    restart)
	$0 stop
	$0 start
	;;
    status)
	echo -n "Checking for service tp-scroll "
	checkproc $TPSCROLL_BIN
	;;
    *)
	echo "Usage: $0 {start|stop|status|restart}"
	exit 1
	;;
esac
