August 2, 2008

Ships Bells Revisited…

Posted in Mac, Mac Software, Productivity at 2:45 am by a11en

A kind reader (Russ P.) shared with me his method for playing the Naval Ship’s Bells (for the daily watch) with us on my About page.  I’ve been meaning to revisit this for a while, ever since my first discussion of Chimes on OsX.  Since I tend to be a fan of the Un*x underpinnings of OsX, I tend to try and use common commands (that are already on your system, that you might not know about) to get these types of tasks done.

For a bit of a review of the methods I’ve used for the Westminster Chimes on OsX, please read my previous post on the topic: Westminster Chimes

I will be using a few of the same tricks here, but I won’t be using one- AppleScript.  For the Ships Bells, AppleScript really isn’t needed.  We’ll be adding 8 lines to our Cron file (using the nice GUI program called Cronnix.  Unlike the Westminster chimes, we don’t have to do any computation to determine the number of times to chime a bell (for the hourly chimes).

First, snag some Ships Bells audio files.  The files here: WxTide Ships Bells are already separated by the number of bells: 1-8 bells.  You of course can use any Ships Bells audio files you like to accomplish this task.  Just be aware that we’re using an approach below that uses a separate file for each type of bell (1-8).

Second, head over to Wikipedia to read about the watches and when the bells are to chime: Wikipedia.  Look closely at that first table… we’ll use it in one second (save it).

Third, if you haven’t done so yet, snag a copy of Play Sound which is a simple program, very easy to call, and we’re going to use it like the following (you can try a variant of this in your

open -a /Applications/ /Users/yournamehere/soundfiles/2bells.wav

That’s a nifty little one-liner that will play a file (here 2bells.wav) with an application you specify (here  For more help on this command, in the terminal type “man open” (manual for open).

Now, the sneaky part is we’re not even going to use AppleScript at all to play the ShipsBells!  Haha!  What we are going to do, however, is to run that CLI command directly from Cronnix (the program that keeps track of when to run things for us).

Fourth, make 8 lines in your Cron file (via Cronnix GUI) to play the bells at the appropriate times.  I do this by simply following along with the table in the Wikipedia article, and adding commas for each field in the Cron file as needed…

An example.. the 1 Bell chime can be seen in the first line of the table in the wikipedia article… and here’s the cron command for it:
30    0,4,8,12,16,18,20    *    *    *    open -a /Applications/playsound/Play\ /Users/yournamehere/ShipsBells/wxtide32_bells/1bells.wav

As you can see, the 1 bell chime plays on the half-hours of the following hours of the day: Midnight, 4am, 8am, 12pm, 4pm, 6pm, 8pm  (this one is funny, because of the Dog Watches).

Actually, with that little example, you can see the power of the simple Cron command… I can accommodate all the Dog watches very easily, where as some programs you can download don’t even do the dog watches.

We completely avoid Applescript because no calculations are required.  We only lose out in that we have 8 lines to add to our cron-file.  But, I don’t think Cron will be mad we added those 8 lines (one for each of the 8 bells specifying exactly when during the day they are to chime).

So, that’s a simple and quick way to add Ship’s Bells to your computer, if you’re in the Nautical mood.

A quick one goes out to Sailorman Jack- Fair Winds, Jack!