Wednesday, November 15, 2006

Beep, SSH, and Perl 101

I typically have my IRC client running on a remote machine in a screen session so that I can SSH from my laptop and attach to that session from anywhere. This is a great system, but the one thing it lacked was audible notification of highlighted messages. For the last few months I've used the script so that any conversation that contains keywords of my choice gets displayed in a little window at the top of my screen. The script is sufficiently small enough that even though I don't know Perl, I was able to modify it so that any special message shows up there. After being away from my keyboard it's nice to know I haven't missed anyone just by glancing at this little window.

The only thing that this system lacked was an audible beep to alert me when these messages arrive. Too often I'm just on another workspace when someone is trying to talk to me, and if I could hear the alert, I could chat back at them. Anyways, irssi does have beep functionality, but it doesn't seem to work very well through an ssh/screen session. Already long story short, inserting one line of Perl into the hilightwin script solved the problem in a rather hackish, but effective manner.

system("ssh hostname beep -f 100 -l 50 -r 2 &> /dev/null");

This command simply opens an ssh session with my laptop (exchange hostname with the actual hostname, of course), and runs the beep command producing two relatively low, short beeps. They are easily distinguishable from the normal system beep. If passwordless logins are enabled, then you're golden. Not many people talk to me so this really doesn't add much traffic to my network :)

1 comment:

  1. Another easier way to get beeps is to simply press CTRL+a CTRL+g inside screen.

    This toggles between visible (white flash of the whole screen) and audible (the beep) bell.

    If this doesn't help, try the author's solution via ssh ;-)