Feb 21 2008

Crème Rappel v2

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.


Feb 13 2008

echo “~lart launchd” | at now

If you’re an old UNIX die-hard using Leopard (and I think Tiger as well) you may have noticed that at doesn’t seem to work. That’s because launchd (How do I hate thee? Let me count the ways…) has subsumed atd as well as all the other useful scheduling things like cron and friends. at’s manpage doesn’t tell you there is no atd, and implies that cron calls atrun every five minutes (incidentally, atrun’s manpage says every ten minutes). Apparently in Tiger the manpage was more helpful, telling you how to enable at jobs with launchd, but no more.

If you do want to enable at functionality, this is the trick:

launchctl load -w /System/Library/LaunchDaemons/com.apple.atrun.plist

Be warned that it’s apparently disabled by default due to power management concerns, so it might not be laptop-friendly. I’m going to see if it makes a noticeable difference to my laptop usage and/or battery life over the next few days and if it does I’ll blog it.

Launchd runs atrun every 30 seconds. This is configurable by hacking the plist file mentioned above.