Tuesday, November 18, 2014

OS X and Power Input Status From the Command Line

The other night I was getting ready to head to my apartment when a tweet from ConEd, the power company, said that several residents near my area were reporting a power outage.

While ConEd charges, in my opinion, way too much, and their website tends to leave something to be desired, they do at least have a site that charts power outages. I confirmed that yes, the address they tweeted was near my apartment. Then I swore because I was planning on recording an episode of my podcast and a power outage would be a real pain to deal with; do I travel an hour to get back to the apartment and risk the power being out, or do I wait and record at the office and end up getting back really late at night?

I then wondered; my laptop is connected to the wall for power. What if it could tell me if it was on AC power? Just being able to connect means nothing. I have a small UPS connected to the router and cable modem, and the laptop battery will keep the laptop going even if power were out. But it turns out OS X can report whether it's on battery or AC power.

From the command prompt I ran:

pmset -g batt

Now drawing from 'AC Power'
-InternalBattery-0 100%; charged; 0:00 remaining

And there it was. My apartment still had power! How handy!

No comments:

Post a Comment