Last active
March 21, 2019 13:33
-
-
Save dmig/748470911f63d1f75670c019c1688c51 to your computer and use it in GitHub Desktop.
simple bash script to view hardware temperatures
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 | |
# ignore sensors by names (this string must contain full sensor names) | |
IGNORE='INT3400 Thermal acpitz' | |
RED='\033[1;31m' | |
GREEN='\033[1;32m' | |
YELLOW='\033[1;33m' | |
BLUE='\033[1;34m' | |
NC='\033[0m' # No Color | |
for t in /sys/class/thermal/thermal_zone*; do | |
type=$(cat "$t"/type) | |
if [[ $IGNORE == *$type* ]]; then | |
continue | |
fi | |
temp=$(cat "$t"/temp); | |
printf "%14s" "$type: "; | |
if (( temp < 26000 )); then | |
echo -ne "$BLUE"; | |
elif (( temp > 75000 )); then | |
echo -ne "$RED"; | |
elif (( temp > 60000 )); then | |
echo -ne "$YELLOW"; | |
else | |
echo -ne "$GREEN"; | |
fi | |
tl=${#temp} | |
dp=$((tl - 3)) | |
echo -e "${temp:0:dp}.${temp:dp:1} ℃$NC"; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment