<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>The Party Line</title>
    <link rel="alternate" type="text/html" href="http://blog.tobez.org/" />
    <link rel="self" type="application/atom+xml" href="http://blog.tobez.org/atom.xml" />
    <id>tag:blog.tobez.org,2010-01-06://3</id>
    <updated>2009-03-01T12:07:13Z</updated>
    <subtitle>tobez&apos;s personal weblog</subtitle>
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type 5.01</generator>

<entry>
    <title>Irssi events notifier with Erlang</title>
    <link rel="alternate" type="text/html" href="http://blog.tobez.org/2006/07/irssi-events-notifier-with-erlang.html" />
    <id>tag:blog.tobez.org,2006://3.50</id>

    <published>2006-07-25T18:04:28Z</published>
    <updated>2009-03-01T12:07:13Z</updated>

    <summary> Once upon a time I was a reasonably happy user of XChat. It had a feature: you could configure it to automatically popup a new window &#8220;in your face&#8221; for private messages. This was nice, since you would never...</summary>
    <author>
        <name>tobez</name>
        
    </author>
    
        <category term="Erlang" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Hints" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en-us" xml:base="http://blog.tobez.org/">
        <![CDATA[<p><img src="http://www.tobez.org/images/blog/irssi-dockapp.png" alt="irssi dockapp" /></p>

<p>Once upon a time I was a reasonably happy user of 
<a href="http://www.xchat.org/">XChat</a>.  It had a feature: you could configure
it to automatically popup a new window &#8220;in your face&#8221;
for private messages.
This was nice, since you would never miss a message directed to you.
The feature also had drawbacks:</p>

<ul>
<li>once a window was there, no popping up occured;</li>
<li>popping up in your face was annoyingly intrusive;</li>
<li>it was common to be typing something else and pressing ENTER
without noticing;  the <code>:wq!</code>&#8217;s in chat windows were numerous;
parts of passwords for folks to see were not unheard of.</li>
</ul>

<p>After some time, and following an advice from friends,
I switched over to <strong>the</strong> IRC client, <a href="http://irssi.org/">irssi</a>,
and never looked back.</p>

<p>I, as many others, run irssi in text mode
(although it supposedly has a GUI, I was never tempted to try it).
Moreover, I run it 24/7 under <a href="http://www.gnu.org/software/screen/">screen</a> control on a reasonably
stable and well-connected machine.</p>

<p>Which presents me with the problem that XChat popup windows were
trying to solve: I miss stuff.  There are various notifiers
available for some instant messaging applications.
I would not be surprized if some of those are easy to integrate
with irssi.  But with <em>remote</em> irssi?  On one or more of my <em>several</em> desktops?
I never heard of such a beast, and so I decided to write one.</p>

<p>The question of presentation solved itself easily:
I use <a href="http://fluxbox.org/">fluxbox</a> window manager, which, among other things,
provides support for <a href="http://www.afterstep.org/">AfterStep</a> and <a href="http://www.windowmaker.info/">WindowMaker</a> dockapps.</p>

<p>Getting information about events from irssi itself turned out to be
a piece of cake, thanks to the tight integration of irssi and <a href="http://www.perl.org/">Perl</a>.</p>

<p>The question of delivering notifications from the machine irssi is being run on
to one or several desktops was somewhat trickier.
Initially, I thought that <a href="http://iswest.tobez.org/">a very-very simple web storage system I wrote</a>
will be the ticket.
It worked reasonably well,
but I did not want to perform the polling more often than every 30 seconds,
and I was not satisfied with the delay.
The help came from an unexpected side.</p>

<p>Some time ago I started to read up on <a href="http://www.erlang.org/">Erlang</a>,
and was impressed with its capabilities for concurrent and distributed processing.
So I sought to re-implement ISWEST-based irssi notifier in Erlang as a sort of a
novice programming project.</p>

<p>The end result is a piece of software called, not surprizingly, <strong>irssi-notifier</strong>,
which can be downloaded <a href="http://www.tobez.org/download/irssi-notifier-latest.tar.gz">here</a>.  It consists of three components.</p>

<h3>activity-notifier</h3>

<p>This is a Perl script which should be loaded in irssi.
Copy it into <code>~/.irssi/scripts</code> directory, and load it into irssi using
the following command:</p>

<pre><code>/script load activity-notifier.pl
</code></pre>

<p>You will need the <code>nc</code> program (netcat) installed,
since I could not be bothered with more socket programming in Perl.</p>

<h3>notifier-server</h3>

<p>This is a small (less than a hundred lines of code)
Erlang program that serves as a middle point between
irssi (with activity-notifier) and your desktop.
Normally, it should run on the same machine as irssi itself.</p>

<p>This is a server program, so it is supposed to run indefinitely.</p>

<p>Since I do not know (yet) how to create proper Erlang applications,
it should be started like this:</p>

<pre><code>$ cd irssi-notifier/notifier-server
$ erl
&gt; c(notifier).
&gt; notifier:start().
</code></pre>

<p>Then leave that Erlang instance running (background it, or something).</p>

<p>I intend to make this somewhat more convenient to use once I learn how
to package a proper Erlang application which runs as a daemon together with
Erlang runtime.</p>

<h3>irssi-dockapp</h3>

<p>This is a C program which actually implements the dockapp.</p>

<p>Compile it (a very simple Makefile is included).
You will need <a href="http://solfertje.student.utwente.nl/~dalroi/libdockapp/">libDockApp library</a> installed first.
Then run it like this:</p>

<pre><code>./irssi-dockapp -t host.where.notifier-server.runs -p 5679
</code></pre>

<p>When irssi receives a private message for you or a message that
it hilights (such as messages with your nick mentioned) an irregularly
shaped red blob will appear in your dockapp almost instantaneously.</p>

<p>There is no limit on the number of simultaneous dockapp connections to
the notifier server.</p>

<p>Enjoy!</p>
]]>
        

    </content>
</entry>

</feed>
