dotfiles/.config/polybar/cpu_info.sh

21 lines
951 B
Bash
Raw Normal View History

2021-12-06 17:37:34 +01:00
#!/bin/sh
2022-01-28 16:28:37 +01:00
check_sensor=$(sensors | grep "Tdie:" 2> /dev/null)
if [ -z "${check_sensor}" ] ; then
check_sensor=$(sensors | grep "Tctl:" 2> /dev/null)
if [ -z "${check_sensor}" ] ; then
CPU_USAGE=$(~/.config/polybar/cpu_load.sh -p)
echo "$CPU_USAGE" | awk '{ printf(" CPU:%6s \n"), $1, $2 }'
else
TEMP=$(sensors | grep 'Package id 0:\|Tctl' | grep ':[ ]*+[0-9]*.[0-9]*°C' -o | grep '+[0-9]*.[0-9]*°C' -o)
#CPU_USAGE=$(mpstat 1 1 | awk '/Average:/ {printf("%s\n", $(NF-9))}')
CPU_USAGE=$(~/.config/i3blocks/cpu/cpu_load.sh -p)
echo "$CPU_USAGE $TEMP" | awk '{ printf(" CPU:%6s @ %s \n"), $1, $2 }'
fi
else
TEMP=$(sensors | grep 'Package id 0:\|Tdie' | grep ':[ ]*+[0-9]*.[0-9]*°C' -o | grep '+[0-9]*.[0-9]*°C' -o)
#CPU_USAGE=$(mpstat 1 1 | awk '/Average:/ {printf("%s\n", $(NF-9))}')
CPU_USAGE=$(~/.config/i3blocks/cpu/cpu_load.sh -p)
echo "$CPU_USAGE $TEMP" | awk '{ printf(" CPU:%6s @ %s \n"), $1, $2 }'
fi