Matthew Hutchinson

Irssi, screen, fnotify and Growl on OSX

8 comments

Occasionally you’ll find me in IRC using the old school Irssi client. Its a simple and powerful IRC client that most importantly, I can launch on any unix based server and leave running in a screen session. A little something like this;

screen irssi
# Ctrl+A,D to unhook this screen
# screen -x to jump back into it (when you've only 1 screen open)

Doing this on a remote server, means I’m always connected to IRC. I can easily jump back in to previous conversations by ssh’ing to the server and switching to the screen.

What I wanted was a growl notification every time my name (nick) was mentioned in a room, or I received a private message. I stumbled on a few blog posts explaining how to do this, but came across a few gotchas on OSX, so here goes another explanation.

fnotify

First, on the remote server (where irssi will run under screen), add the fnotify script to your own ~/.irssi/scripts folder. This is a handy perl script that will write any messages referencing your nick, to a local file (by default ~/.irssi/fnotify). fnotify is a good, simple example of irssi perl scripting.

Don’t forget (as I did) to load this script in irssi with the following command (or setup irssi to auto load it on startup, some instructions here)

/script load fnotify.pl

Check this is working by having someone mention your name in a chat room (or pm you). You should see the ~/.irssi/fnotify file fill with these messages.

Growl

Next on OSX, install growl (if you haven’t already) and be sure to install the growlnotify script (make it executable and in your PATH e.g. /usr/local/bin) Test its working in your OSX terminal with something like;

growlnotify -m 'it works!'

SSH & connection script

Now if you haven’t already got one, create an SSH user with a key to login to your remote server. The key can have a pass-phrase. If you do choose to set one, for the following script to run without interruption, you’ll have to let OSX remember the pass-phrase in its key-chain.

Finally the client script, in OSX create the following script in ~/irssi_growler

#!/bin/sh

(ssh ssh_username@your_server.com -o PermitLocalCommand=no  \
  ": > .irssi/fnotify ; tail -f .irssi/fnotify " |  \
while read heading message; do                      \
  growlnotify -s -t "${heading}" -m "${message}";      \
  say "${heading} says, ${message}";                \
done)&

Replace your ssh_username and your_server.com details, make it executable (644) and run it. This script does the following;

  • opens an ssh connection to your remote machine
  • runs the tail -f command to remotely tail the ~/.irssi/fnotify command
  • the output of which is piped to a read while loop
  • in this loop each message is sent to growlnotify, and (for an audio bonus) to the say command too :)
  • the growl message is set to be sticky (-s) and will stay onscreen until you click to hide it

Launch at startup

After numerous attempts (on Snow Leopard) trying to get this script automatically launching at startup (using launchctl, .plist’s, automator etc. etc.) I opted to just add the script to my login items. This does leave a Terminal window open every-time I login, but I can live with that for now. If someone can explain how properly add a bash script to launch on startup (as a daemon) on the latest Snow Leopard, please let me know.

The final caveat I hit was my firewall. It was smart enough to close any open SSH session after a period of inactivity. This kept killing the irssi_growler script. To prevent this I changed my ssh client config (in /etc/ssh_config) with the following ‘keep alive’ settings;

ServerAliveInterval 150 # can be adjusted higher or lower
ServerAliveCountMax 3

In the future I might re-write fnotify to do more that just write to file. It could potentially send the message data via tcp/ip to the a growl client (set to accept incoming connections).

Soot

no comments yet, post one now

... but hackers use their offices for more than that: they use their office as a place to think in. And if you're a technology company, their thoughts are your product. So making hackers work in a noisy, distracting environment is like having a paint factory where the air is full of soot.Paul Graham, Great Hackers (Oscon 2004)
August 20, 2010 18:30 by

iPhone 'bulbs' wallpaper

no comments yet, post one now

iPhone bulbs wallpaper

Created from my photo of the dark basement ceiling in The Book Club, London, covered with hundreds of lightbulbs

(this works well as a dark backdrop against your iPhone icons)

Le Mans Classic, Laurent Nivalle

no comments yet, post one now

Le Mans Classic

Le Mans Classic Laurent Nivalle, classic cars, incredible race, amazing photography

FAQtory update

no comments yet, post one now

Its been a while since I mentioned anything about the FAQtory app. Rest assured that, along with Bugle it’s been keeping me busy in my spare time!

To re-cap quickly, the FAQtory (pronounced Factory) is a simplified stackoverflow-like question and answer app. It allows you to Ask and Answer questions on any topic you like. The app is entirely content-focused and deliberately simple. A simple user voting mechanism ensures the most popular questions and most correct answers filter to the top.

Looking at the logs, it was last August when I kicked off the very first commit. After almost a year of on-again, off-again work and long periods of inactivity, last week finally saw it launch! In its current form the FAQtory is deployed for a single account, (pmfaqtory.com) – you can take a look here. Over time PMfaqtory intend to use FAQtory to build a resource of project management questions and answers.

This is a big milestone for me and with all features locked down for launch, I can concentrate on preparing for a general release. This will involve adding an account model, pricing options and payment gateway integration. I’ll also be moving the app to a new server stack and cloud based host.

Over the coming weeks I hope to talk more about some the design and technology decisions I have made so far. For a bit of fun, here is a replay of the Git log using the latest Gource visualisation engine (now with added ‘Bloom’ effect!)

music is 'Penguin' by the Books

Gource is now available on Mac Ports which is a much easier install than it used to be (again, compiling from source stills give errors on FTGL)

Zenith New Vintage 1965

no comments yet, post one now

Zenith New Vintage 1965, 2010 edition

You may have heard the news on my recent engagement. Not to be outdone in the proceedings, I took it upon myself to buy a new watch. I haven’t been a ‘watch wearer’ for years, always resorting to pull whatever gadget or phone I had out of my pocket for the time. No longer!

I’ve been a long time fan of Zenith and I’m now the proud owner of their 2010 edition, New Vintage 1965 automatic.

I was surprised to find out just how hard this particular watch is to find. Apparently you must specifically order it from Zenith through an authorized Zenith reseller, and after trawling around every swiss watch shop in London, I had lead times from 6 to 1 month. I went with Harrods, they had the original 1965 model in stock (for trying on), excellent customer service and they could have a new one ready for collection in 2 weeks.

I’ve been happily wearing it daily for the last couple of weeks and its running well. It is an automatic, so after initial winding you must wear it daily for the first 12 days to get it trained to your wrist’s movements.

RVM, REE and Postgres on OSX Snow Leopard

2 comments

I have jumped on board the RVM bandwagon for managing my development environments. I recently sold my Mac Pro on eBay and have a fresh new 27" iMac on the way. So I thought I’d document this part of the install process and a couple of gotcha’s.

First, grab the Postgres one-click installer and run it. Or you can build & compile it from source. Then for RVM and the latest REE follow these instructions;

# install readline for OSX if needed - check if it already exists in /usr/local/lib
wget ftp://ftp.cwru.edu/pub/bash/readline-6.1.tar.gz
tar -xvzf readline-6.1.tar.gz
cd readline-6.1
./configure && make && sudo make install

# install RVM from github
bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
 
# edit your .bash_login (or profile) and add this at the bottom
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"

# check RVM has installed OK, look for 'is a function'
. ~/.bash_login
type rvm | head -n1
rvm notes

# install REE, or whatever Ruby you'd like
rvm install ree -C --enable-shared,--with-readline-dir=/usr/local

# show what rubies are installed
rvm list

# set REE as the default and current ruby
rvm --default ree

# check your working directories
which ruby && which gem

# In general I use Bundler for apps, but for .irbrc and some scripts I need these too
gem install wirble awesome_print hirb bundler mysql heroku

# and finally for the postgres (pg) gem
sudo env ARCHFLAGS='-arch i386' gem install pg

I’m surprised by how few steps it takes these days (to get Ruby & Rails up and running with a database), four years ago this was a different story altogether. With tools like RVM and Bundler, it couldn’t be simpler.

July 02, 2010 13:13 by

The poor man's backup, backup plan

no comments yet, post one now

My primary backup is Time Machine set to auto-backup my entire machine to a single 1TB drive (including all my iTunes media and applications). This way I can do a full restore if I ever need to. BUT, what happens when that drive fails? I needed a remote, off-site backup for my essential files. The stuff I just couldn’t afford to loose if Time Machine died.

I wanted a solution that was simple, fast, efficient (incremental and deletes redundant files), secure and wouldn’t cost the earth. After researching different options (MobileMe, Dropbox, S3, iDrive, mozy) I found that I could simply use rSync over SSH with my Dreamhost. Here’s how …

I already use Dreamhost to host some legacy websites, and they offer unlimited storage space on even their cheapest hosting plan. Per/Gb its way more cost effective than Amazon S3. I setup the following bash script to run these rsync commands on a daily cron interval (where mydhserver.dreamhost.com is my remote dreamhost server)

#!/bin/bash

# send via rsync using SSH
rsync -azP --delete --delete-excluded --exclude-from=/Users/matt/.rsync_exclude.txt /Users/matt/Documents mydhusername@mydhserver.dreamhost.com:~/rsync_backup
rsync -azP --delete --delete-excluded --exclude-from=/Users/matt/.rsync_exclude.txt /Users/matt/Sites mydhusername@mydhserver.dreamhost.com:~/rsync_backup
rsync -azP --delete --delete-excluded --exclude-from=/Users/matt/.rsync_exclude.txt /Users/matt/work mydhusername@mydhserver.dreamhost.com:~/rsync_backup
rsync -azP --delete --delete-excluded --exclude-from=/Users/matt/.rsync_exclude.txt /Users/matt/resources mydhusername@mydhserver.dreamhost.com:~/rsync_backup
rsync -azP --delete --delete-excluded --exclude-from=/Users/matt/.rsync_exclude.txt /Users/matt/workbench mydhusername@mydhserver.dreamhost.com:~/rsync_backup

I have a separate rsync_backup user setup on my Dreamhost account using an SSH key pair without passphrase. Make sure sure that ~/rsync_backup exists on your remote server before running this. The .rsync_exclude.txt file simply contains a list of file patterns to exlude from backups, mine looks like this;

Steam Content
.svn
.DS_Store

rSync will use SSH by default when sending your data (so its encrypted over the wire). However, you should remember that your backed up data (on the remote machine) is NOT encrypted, it is only as secure as the server it resides on.

So rSync is cheap, simple, fast (you can tweak SSH options to make it faster/slower), incremental and secure. Here’s a few helpful links on configuring your rSync backups further.

Engaged!

no comments yet, post one now

Damiani Armonia Solitaire

Just a quick post to announce that about one month ago Elisa and I got engaged in Florence, Italy. Here are a few photos from our trip.

We managed to pick up this little ring in Damiani (who were very helpful in getting it re-sized before we left —thanks to Mr. Filippo Gossi). We liked Florence so much, we might even consider having the wedding there! We visited the Tuscan countryside on a couple of Vespa scooters and saw plenty of great locations.

The Go Team! - Everyone's a VIP to Someone

no comments yet, post one now

May 19, 2010 21:50 by
← (k) prev | next (j) →