-
-
Save jondthompson/11c4f27d4f3c88946659 to your computer and use it in GitHub Desktop.
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 "scale = 2; $temperature / 100.0" | bc` | |
echo "AppleSmartBattery Temperature: " | |
echo $temperature_celsius °C | |
temperature_fahrenheit=`echo "scale = 2; ($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 |
@jondthompson Do you know if this sensor is physically located in the battery? And if so, if there is a way to find cpu temp using ioreg?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fixed a bug mentioned by bkovitz in the comments of the original gist.