The Growling Doorbell
As promised in my previous post, I now have my doorbell sending growl notifications. Sending just one to my mac mini in the living room would be a bit pointless, since at that point I am within three metres of the front door – but, I have the notifications forwarding to every other mac in the house, and even with push notifications to my iPhone. This means that I now get three notifications on my iPhone when the doorbell is rung… One for the Twitter direct message, one for the email for the Twitter direct message, and one for the Growl notification, but they are non-sticky notifications so I can live with that.
Firstly, I installed Prowl – the excellent forwarding mechanism to get growl notifications on your iphone. I had to install on the iPhone as well, of course. I set it up to still show regular notifications, and to only forward items with a priority of at least “High” to my phone so I don’t get inundated with DropBox and Hardware Growler updates vibrating my phone all the time. It doesn’t support the icon images sadly that Growl does, but you can’t have everything (and I imagine this is an iPhone shortcoming rather than a Prowl restriction).
The next step is to install growlnotify (thanks to ZeissS for pointing this out). I had seen growlnotify in the Extras folder for Growl many times, but never really messed with it before. It’s a command line interface for sending local (or networked) growl notifications. It turns out the syntax is pretty simple.
For my purposes I was interested in showing a title saying the doorbell had been rung, a picture of the person ringing the bell, and the date and time that it occurred. According to the documentation the switch
--name should identify the application that is sending the notification, as well as showing the title for the notification. It states also:
To be compatible with gNotify the following switch is accepted: -t,--title Does nothing. Any text following will be treated as the title because that's the default argument behaviour
I found that
-n did not work as I expected, and I actually had to use
-t as well. Perhaps the documentation is outdated? YMMV.
So, to the AppleScript. The only thing I needed to pass was the image which we have already located in the script in the previous post.
on growlNotify(img) set date_ to (current date) as string set scriptpath to "/usr/local/bin/growlnotify -p High -n Doorbell -t "Doorbell Rung!" --image " & img & " -m "" & date_ & """ do shell script (scriptpath) end growlNotify
Nice and easy. This displays a notification something like this:
Then, I just modified the original script to include a call to this immediately after this line:
[sourceode]set the item_path to quoted form of the POSIX path of itemadded[/sourcecode]
[sourceode]set the item_path to quoted form of the POSIX path of itemadded
Job done? Almost. Now, I needed to forward the growl notifications to any other Macs I have. Unfortunately, there is no “global announce to subnet method” I could figure out easily, but Growl does have this functionality built-in. In your Growl preference pane, under “Network”, enable “Listen for incoming notifications on each machine”. You can add passwords if you share your network with other people. Then, on the machine that will be forwarding the notifications, in this pane check “Forward notifications to other computers”. The computers should automagically show up in the list (via Bonjour) then you can just check “Use” for each one.
Job done! Your doorbell is now probably better connected than some politicians.
The next step is to implement proper authentication with Twitter, and try to find a service rather than TwitPic so everyone ringing my doorbell isn’t presented to anyone who wants to spend the (minimal) time trying to figure out how to see them.