articles tagged with snow leopard

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).

Gource on OSX (Snow Leopard)

9 comments

Some months ago I played around with code_swarm by Michael Ogawa – partly for fun and partly to see what all the fuss was about with the Processing framework (something I have yet to really investigate). Last week I came across Gource another source code visualisation tool this time using 3D rendering.

Software projects are displayed by Gource as an animated tree with the root directory of the project at its centre. Directories appear as branches with files as leaves. Developers can be seen working on the tree at the times they contributed to the project.

Some recent commits to the project fixed build issues on OSX. Despite these fixes I still had trouble compiling. So in summary here’s what I did to get it working. Note that I did resort to installing mac ports (something I’d rather NOT do) – after many attempts to download and manually compile the prerequisites (FTGL 2.1.3~rc5-2 kept giving me problems)

# get mac ports
http://www.macports.org/install.php

# get all the ports you need for gource
sudo port install pcre libsdl libsdl_image ftgl

# get and build Gource from github and follow the instructions in INSTALL
git clone git://github.com/acaudwell/Gource.git
cd Gource
autoreconf -f -i
./configure && make && sudo make install

# navigate to your project directory and type;
gource

# have a look at all the options
man gource

# here are the settings I used (to get a large user icon and change the speed/size
gource ./ -s 0.5 -b 000000 --user-image-dir ~/images/avatars/ --user-scale 2.0 -800x600

# video it in h264 using ffmpeg, first install ffmpeg via mac ports (with codecs)
sudo port install ffmpeg +gpl +lame +x264 +xvid

# pipe PPM images to ffmpeg to generate a h264 encoded movie
gource ./ -s 0.5 -b 000000 --user-image-dir ~/images/avatars/ --user-scale 2.0 -800x600 --output-ppm-stream - | ffmpeg -y -b 3000K -r 60 -f image2pipe -vcodec ppm -i - -vcodec libx264 -vpre hq -crf 28 -threads 0 bugle.mp4

# finally, if you want to add some audio to the video (from an mp3)
ffmpeg -i audio.mp3 -i bugle.mp4 -vcodec libx264 -vpre hq -crf 28 -threads 0 bugle-with-audio.mp4
(this output will be the length of the video/audio track, whichever is longer)

# phew! - now go here to see how to remove macports when you're done :)
http://trac.macports.org/wiki/FAQ#uninstall

Bugle did exist (for a time) as an open source project on github before I moved it to be privately hosted. So here is the result; Bugle’s git log from April ’09 to the present parsed through Gource, with just one committer (me).

In summary you can see real bursts of activity at the start followed by some long periods of inactivity, and coming toward the present date renewed development and work going on. Gource is more impressive when visualising big projects with multiple committers over long periods, like the history of Git itself for example.

← (k) prev | next (j) →