|
etc :: morningperson
It probably reveals more than you ever wanted to know about my personality if I say that, after years of trying to develop a good habit of waking up early, it suddenly became much easier for me to do once I began to see it as a form of mortification of the flesh (or at least, as a spiritual discipline). I've been awake at 6:00 nearly every day in the last month, helped in part by a schedule maintained by my computer:
- 21:45 - Mac OS X has an option in the "Energy Saver" control panel to schedule system sleep and wake-up times. But the OS is much too nice about it - if you're busy doing something, it will defer the shutdown without so much as notifying you that it wants to go to sleep. Fortunately there's a much more immediate way to put the system to sleep: the "$pmset sleepnow" power manager command, which net.zahniser.sleepnow calls.
- 05:58 - My alarm clock goes off. About three years ago I disassembled it and carefully but irrevocably disabled the Snooze button to keep myself from abusing it. That worked for a year or so, but has been losing effectiveness recently. But the alarm now is really just to warn me to begin preparing myself to get out of bed, because also at 5:58 the computer automatically wakes itself from hibernation and begins preparing the next attack...
- 06:00 - The net.zahniser.makenoise daemon calls a new version make noise, which loads a YouTube video, the muppets version of Ode to Joy.
- 06:01 - I get out of bed, turn on the lights, and only then turn off the muppets.
I'm guessing that nearly everyone reading this page will find it useful only as an example of what launchd can do and how to set up daemons. But if you want to set up your comupter with the above scripts, copy the following scripts to somewhere on your hard drive:
make noise.applescript
Then, download the following plist files, modify them to point to wherever you installed the scripts, and copy them into /Library/LaunchAgents. Note that because launchd does not run as your user account, you cannot specify the script locations relative to your home directory (e.g. "~/Scripts/make noise.applescipt" will not work in a launchd plist file).
net.zahniser.sleepnow.plist
net.zahniser.makenoise.plist
The old method, which didn't work as well, was:
- 21:45 - A daemon launched by net.zahniser.gotosleep calls go to sleep: using the "say" terminal command, my computer cranks up its voice to maximum volume and announces, in a voice that made me jump about a foot in the air the first time it caught me by surprise, "I am going to sleep in 15 minutes, and so should you."
- 22:00 - Mac OS X has an option in the "Energy Saver" control panel to schedule system sleep and wake-up times. But the OS is much too nice about it - if you're busy doing something, it will defer the shutdown without so much as notifying you that it wants to go to sleep. Fortunately there's a much more immediate way to put the system to sleep: the "$pmset sleepnow" power manager command, which net.zahniser.sleepnow calls.
- 06:30 - My alarm clock goes off. About three years ago I disassembled it and carefully but irrevocably disabled the Snooze button to keep myself from abusing it. That worked for a year or so, but has been losing effectiveness recently. But also at 6:30, the computer automatically wakes itself from hibernation and begins preparing the next attack...
- 06:35 - The net.zahniser.makenoise daemon calls make noise, which has the computer crank up its volume all the way and begin blasting the first piece of music it can get its hands on. At 6:30 I may have been tempted to get out of bed for just long enough to disable this daemon and go back to sleep. But the only way to kill it is to bring up a shell, become root, navigate to the /Library/LaunchAgents directory, move or delete the daemon's plist file, and restart the computer. And by the time I'd done all that, I'd be awake anyways.
- Taking a carrot-and-stick approach, as soon as the music starts playing the computer also launches Mirth, so that the first thing I'll see as I stumble out of bed and hunt for the Mute button is the day's comics. This gesture of goodwill on the part of my computer is designed to forestall and acts of violence against it.
|