We use IRC at work for most of our office communication. I’ve tried various IRC clients over the years (mIRC, xchat, pidgin, chatzilla among others) but often I’ve found myself  going back to irssi. As most irssi users, I run it under a screen session on my Linux desktop. This way when I’m at a meeting I can still re-attach to the same screen session from my laptop and continue discussions where I left off without having to constantly connect/disconnect and probably miss half of the discussion in the process. I also hate spamming my co-workers with join/quit messages.

Some days I’m rarely at my desk and spend most of the day either in a meeting or debugging/testing something or other somewhere around the office. This is annoying to people that need to ask a quick question and I don’t notice their message until I eventually get back to my desk many hours later or when someone drops by my desk looking for me and I’m nowhere to be found.

This lead me to the wonderful idea of connecting my iPhone to irssi in order to automatically set my away status when I’m not at my desk. This, of course, would require that I always plug my iPhone to my desktop when at my desk.  But since I usually dock my iPhone on its stand (which is connected to my desktop)  whenever I’m at my desk this would not be a problem.

This was achieved using a simple irssi script that uses lsusb to check if my iPhone is connected or not. Should basically work with any usb device as long as it has a unique identifier. In my case I use my iPhone’s serial number as the identifier.

Here is the script:

## Sets you away in irssi when iPhone not conencted
## Put me in ~/.irssi/scripts/autorun

use strict;
use Irssi;
use vars qw($VERSION %IRSSI %config);

my $iphone_serial="12345";

Irssi::command_bind('iphoneaway', 'cmd_iphoneaway');

my ($iphoneaway_tag, $away_state);
$away_state = 0;

sub cmd_iphoneaway {
    my ($data, $server, $witem) = @_;
    my $interval = 20;

    if ($data =~ /^[0-9]+m$/) {
        $interval = $data * 60;
    } elsif ($data =~ /^([0-9]+)s?$/) {
        $interval = $1;
    } elsif ($data =~ /clear/) {

        if (defined($iphoneaway_tag)) {
            $iphoneaway_tag = undef;
            Irssi:print("iphoneaway disabled");

    if (defined($iphoneaway_tag)) {
        $iphoneaway_tag = undef;

    $iphoneaway_tag =
      Irssi::timeout_add($interval*1000, "iphone_check", "");
    Irssi:print("iphoneaway enabled with $interval second interval");


sub iphone_check {
  my ($data, $server) = @_;
  my (@servers) = Irssi::servers();
  $server = $servers[0];

  #Irssi:print("Checking if iphone is connected ...");

  my $rc = system("lsusb -v 2> /dev/null | grep -q \"$iphone_serial\"");
  if ($rc == 0){
    #Irssi:print("Iphone is connected");
      if ($away_state != 0){
        Irssi:print("Clearing away status");
        $away_state = 0;
  } else {
    #Irssi:print("Iphone is not connected");
    if ($away_state != 1){
        $away_state = 1;
        $server->command("/AWAY Away from desk");

Once loaded I activate it running the iphoneway command in irssi:

[#somechannel] /iphoneaway

This will then check whether my iPhone is connected or not every 20 seconds and clear or set my away status based on that.

Finally the solution is complete using another irssi script to handle messages that are sent to me when I’m away and forwards them to my iPhone using Prowl. For this I use a ready made and excellent script (prowlnotify.pl) written by Denis Lemire.

The final result allows me  to keep track of any messages sent my way regardless of where I’m actually located and my co-workers to easily tell whether I’m actually at my desk or not before deciding to drop by for a chat.