You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

19 lines
546 B

#!/usr/bin/env bash
# This may not always be the CPU sensor on other hardware.
# To be sure we need to iterate through /sys/class/thermal/thermal_zone*/type
# https://www.kernel.org/doc/Documentation/thermal/sysfs-api.txt
temperature_file="/sys/class/thermal/thermal_zone0/temp"
# Check temperature file exists
if [[ ! -f "${temperature_file}" ]]
then
echo "null"
exit
fi
# Read temperature file
temperature=$(cat "${temperature_file}")
# Convert millidegrees celsius to degrees celsius
echo "${temperature}" | awk '{print int($1/1000)}'