In Code and Mac on
1 November 2009 tagged applescript, Code, launchd, macbook, power, ruby with 2 comments
This happens a lot: I’ll be programming along, in the zone, so much that even the low-power alert doesn’t dissuade me from my task:
That’s bad. Because inevitably, I’ll be just in the middle of a thought when the computer shuts off, ten minutes later. I don’t actually lose anything, of course, because MacBooks are usually smart about keeping enough power to stay alive. (Note: haven’t used anything else for a while; other platforms may do just as well. YMMV.)
Still. It happened so much that I decided to do something about it:
I made a new text file, named it "batterywarning" and threw it in /Applications/Scripts/ with the following contents:
#!/usr/bin/env ruby
`pmset -g batt` =~ /discharging; (\d+:(\d+)) remaining/;
if $1 && $1 < '0:10' then
nums = %w{ zero one two three four five six seven eight nine ten }
mins = nums[$2.to_i] ? (nums[$2.to_i] +" minute"+ ($2=='01' ? '' : 's')) : $1
exec "osascript -e 'tell application \"AppleScript Runner\" to "+
"display alert \"Seriously, go plug in your computer.\" "+
"message \"There’s only about "+ mins + " left! "+
"How many times do you need to be told?\" as warning'"
end
The gist: when run, the script checks the current estimated remaining time on the battery. If it’s below 10 minutes (the point at which the native warning appears), it displays its own alert box warning the user of their procrastinatory folly. If there is more than 10 minutes remaining, it does nothing.
I made the script executable (chmod +x /path/to/script), and configured launchd to run it every minute by creating a plist named "com.dbergey.batterywarning.plist" in ~/Library/LaunchAgents/ thusly:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.dbergey.batterywarning</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/Scripts/batterywarning</string>
</array>
<key>LowPriorityIO</key>
<true/>
<key>StartInterval</key>
<integer>60</integer>
</dict>
</plist>
Then, from the command line, I did this to tell launchd about it:
launchctl load ~/Library/LaunchAgents/com.dbergey.batterywarning.plist
And it worked! Hopefully I will be more proactive about plugging in when warned up to 10 times before shutoff.
In Family and Life on
9 August 2009 tagged driving, forest, google maps, looking glass falls, mt. vernon, ohio, south carolina with no comments
Arrived in South Carolina after 10 hours of driving. My parents et al are still stuck in traffic, having left OH shortly after we did (stopped for dinner in Mt. Vernon, but still). I’m very glad we made it.
Google Maps took us all up and around some back roads that said something to the effect of “15mph curves, 4200ft elevation, next 16 miles.” Got to see loads of forest and the Looking Glass Falls as we carefully blew by, but I think we’ll go back a different way, thank you very much.
In Family and Life on
8 August 2009 tagged chlorine, cooler, ice, lasagna, pool, rehearsal, toe, wedding with no comments
Too late to write much tonight.
Suffice to say the wedding rehearsal went well, the lasagna and walnut pound cake was awesome, and after we bought a new cooler and 44 lbs of ice in which to put all the leftovers, it fell out of the car onto Mom’s toe. Yeah, the very same one in the “boot”. Not good.
But she put ice on it, and the rest of us all had a good time in the hotel pool until we all got overwhelmed and/or coughy and/or asthmatic from the chlorine and steam.
In Family and Life on
7 August 2009 tagged concrete, Family, toe with 1 comment
Today my family (parents + siblings remaining at home) was in a minor car accident. Fortunately, there were only minor injuries.
Apparently, a 4-inch-ish piece of concrete struck the windshield of their van while they were traveling to Ohio for my brother’s wedding on Saturday. The glass cut my mom’s arms all up, and the projectile inconveniently struck her in the toe, which is bruised and jammed now.
So if you see her this weekend, that’s why she has a big boot on her foot.
In Blogging on
5 August 2009 tagged mignolo, oulipo, theme, wordpress with 2 comments
Changed my WordPress theme to Oulipo by Andrea Mignolo. I like it because it has nice typography and is still rather minimalist.
I’ve played with some similar ideas over the months/years, but could never seem to get anything together. I don’t have time to make a complete WordPress theme these days anyway.
You might need to use FireFox 3.5 or Safari 4 to see it all. I haven’t looked at it in Internet Explorer yet.
In Mac on
4 August 2009 tagged desktop pictures, stacked displays, wallpaper with no comments
These days I set my laptop directly below my 20” display, which is set up on some books. I really like the setup, as I don’t have to move my head around to interact with the second display; I can just glance down or straight ahead.
I can’t find any nice desktop pictures, though … all the dual-display desktops are for side-by-side configurations. There are “vertical” desktop pictures, too, but they are designed for when you have your display turned 90°.
Has anyone ever seen desktop pictures designed for stacked displays?
In Mac on
4 August 2009 tagged bodega, Mac, reggy, software with no comments
My friend Sam made something helpful a couple of years ago. I still use it from time to time to test regular expression matching.

Now Reggy is on Bodega, your new corner store for Mac apps. Check ‘em both out.
In Bible and Life on
3 August 2009 tagged youredoingitwrong with 2 comments
If you’ve ever said to yourself, “I’m a better Christian than {$person} because I …”
- have a daily “quiet time”
- have certain dress standards
- speak in tongues
- don’t go to movies
- have been baptized
- don’t drink alcohol
- don’t listen to rock music
- never miss a church service
… then you’re doing it wrong.
P.S. I used to think some of these things.
Update: Some people have also had trouble with these:
- don’t eat meat that has been sacrificed to an idol
- don’t eat with Gentiles
- am circumcised
- was baptized by Paul
- was baptized by Peter
- was baptized by Apollos
In Bible and Life on
3 August 2009 tagged brian onken, charlie boyd, emergent church, engage community church, jon hand, science, tim keller, truth with 4 comments
Some of my spiritual influences and education over the past two years:
From Charlie Boyd I learned not to let anyone tell me I need to do anything special or extra to merit God’s favor or attention. Working overtime to “keep all the rules” is not only unnecessary, but dangerous. (See the entire book of Galatians.)
From Brian Onken I learned that God doesn’t need my help to accomplish His purposes. I’m welcome to come along for the ride (and even help out), but God will get done what He wants to get done, with or without me. (Calvin wasn’t all wrong.)
From Tim Keller I learned that it’s okay to believe that Science just might have the answers, and to speculate that Genesis 1 just might be more poetry than narrative.
From Jon Hand I learned that all truth is God’s truth. If something exhibits love, beauty or truth, God can be found therein, regardless if it is labeled Sacred or Secular. And I learned it’s okay to ask the big questions, the REALLY big ones, questions that might earn me funny looks in most churches.
I also learned from Jon and others that I didn’t have to be a Conservative to be a Christian. It’s okay to disagree with the evangelical world’s consensus on social issues like poverty, war, and homosexuality.
Deconstructing and rebuilding one’s faith is a normal, even necessary part of spirituality. Never stop asking yourself why you believe what you believe, and don’t be afraid to change it if necessary.
So. I think I’ve become more Emergent than anything else these days, with a dash of the Reformation thrown in for good measure. In the next few months, Jennifer and I hope to find a community here in Ann Arbor in which to continue our spiritual conversation.