I use
bsflite as my primary AIM client, and I love it. The only problem is that it can't play sounds or anything (afaik). All I want is a sound soon after an IM arrives, one time, and a local nail message that shows who has sent me messages. Here is how I'm currently doing it. I'm sure it's very inefficient, which is why I'm posting here:
Code:
# I always run bsflite through screen -L so this log always exists.
# The reason the last line of the screenlog is important is that if there are no messages,
# the screenlog reads: @:
# if there are messages it reads: @: [screenname] [screenname]
# where screenname is someone who has IMed me.
b=`tail -n 1 ~/.bsflite/screenlog.0`
# This checks if I have the bsflite window open. I'm sure there is a more efficient way.
# The reason I have to put the switches is because the screen is always running,
# but the following line is the line I use to reattach to screen, so this line will only appear
# if I'm actually looking at the AIM client.
c=`ps -Af|grep "screen -D -r bsflite"|grep -v grep`
# This checks a file that I write to later if a sound has already been played.
# Let me know if there's a better way.
d=`cat ~/.bsflite/ims`
# This checks b and c by length, to see if there are messages,
# and to see if the window is open.
if [ ${#b} -ge 7 -a ${#c} -le 7 ] ; then
# This sets SN to just [screenname] without the @:
SN=${b:0:${#b}-4}
# If the length of the current messages is longer than the messages written to file,
# set the volume to a reasonable level, and play a sound
# The A and B save the current volume in case I have it higher or lower, so it can
# play the sound and set the volume back to what it was
if [ ${#d} -lt ${#SN} ] ; then
A=`amixer sget 'PCM'|tail -n 1|awk '{print $4}'`
B=`amixer sget 'Headphone'|tail -n 1|awk '{print $4}'`
amixer sset 'Headphone' 31
amixer sset 'PCM' 15
madplay ~/receive.mp3
amixer sset 'PCM' $A
amixer sset 'Headphone' $B
fi
# This was the best way I could find to delete anything containing Messages from mail.
# The reason I do this is because if I get new IMs, I want only a single mail that shows
# where they came from
echo "delete /Messages" | nail
# Write myself a mail that tells me who has IMed me
nail -s "Messages from $SN" bkam < "."
# Write who has IMed me to file, so that the sound only plays once
echo $SN > ~/.bsflite/ims
fi
Anyway, this is my first linux script basically. Oh yeah, I forgot, when I run another script called aim, it also deletes the mail and does echo "" > ~/.bsflite/ims before running the program, so that when i open the client it removes notifications.
The reason I want this to be efficient is because I run it with crontab all the time, so I don't want it using resources. It seems fairly minimal to me, and running this every five minutes is probably less resources than just running gaim, but the faster/more efficient the better. Tips appreciated.