#!/bin/bash

#
# Input format:
#
# <type>
# <message1>
# <message2>
# ...
#
# Where <type> is either "ping" or "messages"

read mtype

echo "INCOMING: $mtype";

case "$mtype" in
ping)
flash-thinklight.sh &
;;
messages)
msgs=''
while read msg; do
if [ -z "$msg" ]; then
break
fi
if [ -z "$msgs" ]; then
	msgs="$msg"
else
	msgs=$(echo -e "$msgs\n$msg")
fi
done
echo notify-send -t 0 "$msgs"
notify-send -t 0 "$msgs" &
;;
*)
echo "Invalid message type: $mtype"
esac
