54 行
1.6 KiB
Bash
実行ファイル
54 行
1.6 KiB
Bash
実行ファイル
#!/bin/sh -e
|
|
|
|
__cpu_temp_detail() {
|
|
case "$(uname)" in
|
|
"OpenBSD")
|
|
sysctl hw.sensors | grep -E 'hw.sensors.*temp'
|
|
;;
|
|
"FreeBSD")
|
|
sysctl dev.cpu | grep -E 'dev.cpu.*temperature'
|
|
;;
|
|
"Linux")
|
|
local i
|
|
for i in $MONITORED_TEMP /sys/class/hwmon/hwmon*/device/temp*_input /sys/class/hwmon/hwmon*/temp*_input /proc/acpi/ibm/thermal /proc/acpi/thermal_zone/*/temperature /sys/class/thermal/thermal_zone*/temp; do
|
|
[ -r "$i" ] || continue
|
|
printf "%s\n" "$i:"
|
|
cat "$i"/*
|
|
done
|
|
;;
|
|
esac
|
|
}
|
|
|
|
__cpu_temp() {
|
|
local i t unit
|
|
case "$(uname)" in
|
|
"OpenBSD")
|
|
t=$(sysctl hw.sensors | grep -E 'hw.sensors.*temp' | awk '{ print $1 }' | head -1 | sed 's/^.*=//' | sed 's/\..*$//')
|
|
color b k Y; printf "%s" "$t"; color --
|
|
;;
|
|
"FreeBSD")
|
|
t=$(sysctl dev.cpu | grep -E 'dev.cpu.*temperature' | awk '{ print $2 }' | head -1 | sed 's/\..*$/C/')
|
|
color b k Y; printf "%s" "$t"; color --
|
|
;;
|
|
"Linux")
|
|
for i in $MONITORED_TEMP /sys/class/hwmon/hwmon*/device/temp*_input /sys/class/hwmon/hwmon*/temp*_input /proc/acpi/ibm/thermal /proc/acpi/thermal_zone/*/temperature /sys/class/thermal/thermal_zone*/temp; do
|
|
case "$i" in
|
|
*temp*_input|*thermal_zone*/temp)
|
|
[ -s "$i" ] && read t < "$i" && t=$(($t/1000))
|
|
;;
|
|
*)
|
|
[ -s "$i" ] && t=$($BYOBU_SED -e "s/^[^0-9]\+//" -e "s/\s.*$//" "$i")
|
|
;;
|
|
esac
|
|
|
|
if [ -n "$t" ] && [ "$t" -gt 0 ]; then
|
|
color b k Y; printf "%sC" "$t"; color --
|
|
break
|
|
fi
|
|
done
|
|
;;
|
|
esac
|
|
}
|
|
|
|
# vi: syntax=sh ts=4 noexpandtab
|