The Fugue

Counterpoint by Hans Fugal

Crème Rappel v2

Posted by Hans Fugal Fri, 22 Feb 2008 05:19:19 GMT

In the spirit of release early, rewrite often, I have released Crème Rappel version 2. Version 1 was a shell script that combined Growl and at. Then Apple released 10.5.2 not half a week later and broke at altogether. Sick of fighting with launchd and other Apple superiority complexes, I set about to nurture my own superiority complex and rewrite Crème Rappel to be completely independent of at.

Of course, that's getting too heavy for a shell script, so I moved to Ruby. One thing I didn't want was to require a daemon to be running. Daemons can fail or forget to start up, and that means I couldn't really truly trust the tool. The recent at debacle is just another case in point. So, instead I wrote Crème to fork a process that sleeps until the moment of truth, then fires off the reminder. It turns out the obvious function for the job, sleep(), is a poor choice here. In fact, every timer I tried had the same problem, including one I thought would not: setitimer(). When you suspend the laptop, it appears you also suspend time. If you don't believe me, try this simple experiment:

date; sleep 30; date

Put the laptop to sleep during the sleep for a substantial time, then notice that when you resume you still have to wait for the full 30 seconds to tick by even though it has actually been a minute plus since you issued the command. So I sleep for one second intervals instead, checking the time every time.

This is not just a backpedaling rewrite, though. It also adds more flexible and easy-to-type timespecs, and a spiffy website. If you give it a try and it doesn't work, or you struggle with the documentation, please do drop me a line so I can fix it. I want it to be worth every bit of bandwidth that you paid for it.

1 comment |

Growling

Posted by Hans Fugal Wed, 13 Feb 2008 17:20:49 GMT

growlnotify is a little program that comes with Growl which allows you to submit Growl notifications from the command line or from scripts. Unfortunately, it doesn't seem to work properly in Leopard—the notification only shows up maybe ⅓ of the time. There's a hint in the logs, but I have no idea what it means:

2008-02-13 10:09:15 GrowlHelperApp[17821] *** -[NSMachPort handlePortMessage:]: dropping incoming DO message because the connection or ports are invalid

Apparently the devs are pretty clueless about the problem too, as it's been reported but not yet fixed. The folk(s) over at hasseg.org came up with a workaround, which is all well and good, but I observed a simpler workaround than using the network (which requires configuring growl to allow network connections, if I'm not wrong). This little wrapper script does the trick, at least in my initial tests:

#!/bin/sh
wrappee=/usr/local/bin/growlnotify
exec $wrappee -w "$@" &

Basically we tell it to wait for notification from growl that the message is now off the screen, and then go in the background so we don't have to actually wait for it. This has the side effect of essentially rendering the -w option useless when using the wrapper, so I've decided to wrap it with a different name instead of a transparent wrapper. I call it growl, which is both shorter to type and not nearly as ugly as growlnotify. Enjoy.

4 comments |