#!/bin/sh
#
# on/off script to blink the thinklight
#
# by Dennis Gnad <bluedrago@gmx.de>

THINK=/proc/acpi/ibm/light
I=0

if [ $1 ]; then
	COUNT=$[$1*2]
else
	COUNT=5
fi


if [ $2 ]; then
	FREQ=`echo $2*0.01|bc -l`
else
	FREQ=0.5
fi


if [ -f $THINK ]; then

	INIT=`cat $THINK |grep status |sed s/\.*\[[:space:]]\//g`
	
	
	while [ $I -lt $COUNT ]; do 

		case `cat $THINK |grep status |sed s/\.*\[[:space:]]\//g` in
			on)
				echo off > $THINK
				;;
			off)
				echo on > $THINK
				;;
		esac
		
		sleep $FREQ

		I=$[$I+1]

	done


	echo $INIT > $THINK
fi
