Skip to content

Instantly share code, notes, and snippets.

@np
Created January 14, 2010 09:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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