citadel-core/scripts/status/temperature
2022-09-25 17:06:42 +02:00

20 lines
616 B
Bash
Executable File

#!/usr/bin/env bash
# SPDX-FileCopyrightText: 2021-2022 Citadel and contributors
#
# SPDX-License-Identifier: GPL-3.0-or-later
# If vcgencmd is available, use it to get the temperature and exit
if command -v vcgencmd &> /dev/null; then
echo "$(vcgencmd measure_temp)" | cut -d '=' -f 2 | cut -d '.' -f 1
exit 0
fi
RAW_TEMP=$(cat $(grep -sxl "coretemp" /sys/class/hwmon/hwmon*/name | sed 's|\(.*\)/.*|\1|')/temp*_input 2> /dev/null)
if [[ -n $RAW_TEMP ]]; then
echo "$RAW_TEMP" | head -n1 | awk '{print int($1/1000)}'
else
cat /sys/class/thermal/thermal_zone0/temp | awk '{print int($1/1000)}'
fi