Skip to content

Instantly share code, notes, and snippets.

@np
Created January 14, 2010 09:10
Show Gist options
  • Save np/277000 to your computer and use it in GitHub Desktop.
Save np/277000 to your computer and use it in GitHub Desktop.
#!/bin/sh
# LICENSE: Public Domain
ioreg -w0 -c AppleSmartBattery -r | # Getting the info
tail -n +2 | # Skipping the prelude
sed -e 's/" *=/": /g' | # Record field syntax
sed -e 's/\(": .*\)$/\1,/' | # Add commas
ruby -e 'puts STDIN.read.gsub(/,\s*\}/, "}")' | # Removing last extra comma
sed -e 's/Yes/true/g' | # Yes->true
sed -e 's/No/false/g' | # No->false
sed -e 's/(\(.*,.*\))/[\1]/' | # CellVoltage field
sed -e 's/<\(.*\)>/"\1"/' | # ManufacturerData field
json-pp # json pretty-printing
# (& check syntax)
# http://gist.github.com/277001
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment