All pastes #1243684 Raw Edit

Miscellany

public text v1 · immutable
#1243684 ·published 2008-11-03 02:38 UTC
rendered paste body
#!/bin/sh
TL=/proc/acpi/ibm/light
USE_LED=y
USE_TL=n

think_blink() {
	# if the light was on, turn it off then wait briefly before
	# starting blinking pattern
	if [ "$1" == "on" ]; then
           echo "off" > $TL
	   sleep 0.25
	fi

	for i in $(seq 1 $2); do
		echo "on" > $TL
#		echo "0 on" > /proc/acpi/ibm/led
		sleep $3
		echo "off" > $TL
#		echo "0 off" > /proc/acpi/ibm/led
		sleep $4 
	done
	echo $state > $TL
}

#ssh $1 ": > .notify ; tail -f .notify" | \
echo "" > ~/.notify; tail -f ~/.notify | \
sed -u 's/[<@&]//g' | \
while read heading message; do
	state=$(cat /proc/acpi/ibm/light | awk '{if (NR==1) print $2}')

	# irssi public events (highlight)
	if [ "$heading" = "irssi.pub:" ]; then
		think_blink $state 2 0.25 0.25
	fi

	# irssi private messages
	if [ "$heading" = "irssi.priv:" ]; then
		think_blink $state 4 0.25 0.13
	fi

	# pork (IM client) messages
	if [ "$heading" = "pork.priv:" ]; then
		think_blink $state 3 0.5 0.25
	fi

	# pork signon of buddy in thinkblink_pork.pl
	if [ "$heading" = "pork.pounce:" ]; then
		think_blink $state 10 0.13 0.13
	fi
done