Skip to content

Instantly share code, notes, and snippets.

@ngsctt
Last active November 3, 2020 07:59
Show Gist options
  • Save ngsctt/49abba7fc4775211db5a7fd00049b1fe to your computer and use it in GitHub Desktop.
Save ngsctt/49abba7fc4775211db5a7fd00049b1fe to your computer and use it in GitHub Desktop.
#!/bin/bash
# <bitbar.title>CPU Temperature</bitbar.title>
# <bitbar.version>v1.0</bitbar.version>
# <bitbar.author>Nathan Scott</bitbar.author>
# <bitbar.author.github>ngsctt</bitbar.author.github>
# <bitbar.desc>This plugin displays the current CPU temperature, using osx-cpu-temp by @lavoiesl</bitbar.desc>
# <bitbar.dependencies>osx-cpu-temp</bitbar.dependencies>
#
# osx-cpu-temp can be downloaded from: https://github.com/lavoiesl/osx-cpu-temp
# One-liner:
# TEMPD=$(mktemp -d /tmp/osx-cpu-temp.XXXXXXXXXXXX) || exit 1 && (cd $TEMPD && curl -LO https://github.com/lavoiesl/osx-cpu-temp/archive/master.zip && unzip master.zip && (cd osx-cpu-temp-master && make && cp osx-cpu-temp /usr/local/bin/osx-cpu-temp)); rm -rf $TEMPD
TEMPERATURE_WARNING_LIMIT=80
TEMPERATURE=($(/usr/local/bin/osx-cpu-temp))
TEMP_VALUE=${TEMPERATURE[0]}
TEMP_INTEGER=${TEMPERATURE[0]%.*}
TEMP_UNIT=${TEMPERATURE[1]}
if [ "$TEMP_INTEGER" -gt "$TEMPERATURE_WARNING_LIMIT" ] ; then
ICON="🔥"
else
ICON=""
fi
echo "$ICON${TEMP_INTEGER}$TEMP_UNIT| size=12"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment