Pidgin-blinklight replacement for other messengers

One of my favourite plugins for pidgin is pidgin-blinklight, which blinks my ThinkPad’s ThinkLight upon the arrival of new messages. Pretty useful as it is not as annoying (especially for others around you) as playing weird sounds. Unfortunately such a plugin is not available for other messengers like psi - but you’re able to specify your own sound player. So I came up with the following script, which is my default sound player in psi now.

#!/bin/bash

IBMLIGHT="/proc/acpi/ibm/light"

function light_is_on() {
	[ "on" = "`grep status ${IBMLIGHT} | awk '{print $2}'`" ]
	return $?
}

function light_off() {
	echo off > ${IBMLIGHT}
}

function light_on() {
	echo on > ${IBMLIGHT}
}

if light_is_on; then
	light_off
	sleep 0.2
	light_on
	sleep 0.1
	light_off
	sleep 0.2
	light_on
else
	light_on
	sleep 0.2
	light_off
fi

Hint: In case you want a blinking light and sound, just add something like exec /usr/bin/play $@ at the end of the script.