Created
March 5, 2014 18:57
-
-
Save earlonrails/9374070 to your computer and use it in GitHub Desktop.
battery_temperature for mac osx 10.9.2 using ioreg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# battery_temperature for mac osx 10.9.2 | |
if [ `uname` == "Darwin" ]; then | |
if [ "$1" == "-h" ]; then | |
echo "Usage: $(basename $0 ".sh") [option]" | |
echo " -l also show Model Name and Processor Name" | |
echo " -h display this help message" | |
exit | |
fi | |
# -l display Model Name and Processor Name | |
if [ "$1" == "-l" ]; then | |
system_profiler SPHardwareDataType | awk '/Model Name/ || /Processor Name/' | sed 's/[^:]*: //' | awk '{ printf $0 " " }' | |
echo | |
fi | |
# sensor data | |
temperature=`ioreg -r -n AppleSmartBattery | grep Temperature | cut -c23-` | |
temperature_celsius=`echo $temperature / 100.0 | bc` | |
echo "AppleSmartBattery Temperature: " | |
echo $temperature_celsius °C | |
temperature_fahrenheit=`echo "($temperature_celsius * (9 / 5)) + 32.0" | bc` | |
echo $temperature_fahrenheit °F | |
# error message if unsupported machine | |
else | |
echo -e "\nThis appears not to be an OS X machine\n" | |
fi |
Thank you so much! 👍
what about cpu temp?
Using iStats, you get a different reading for the battery temperature than using this. So i collected ˜10 days of by-minute data from both, ioreg and istats. Compared them, ran a linear regression and now i have the theory that the value from ioreg -r -n AppleSmartBattery
is in Kelvin tenths. Does anyone have more info on these units ?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nevermind. Fixed in my fork.