summaryrefslogtreecommitdiffstats
path: root/.local/bin/status/sb-cpu
blob: 3775864cd4865c9ed5552bc6bdf117f16c9f91aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/sh

ncpu=$(sysctl -n hw.ncpu)
ncpu=$((ncpu + 1))
topline=$((ncpu * 2 - 1))

printf "  "
for i in $(top -P -d 2 -s 0.2 | grep '^CPU' | sed -n ${ncpu},${topline}p | rev | cut -d' ' -f2 | rev | cut -d'.' -f1 | awk '{print (100 - $1)}'); do
	case $(echo $i / 12.5 | bc) in
		"0") printf "▁";;
		"1") printf "▂";;
		"2") printf "▃";;
		"3") printf "▄";;
		"4") printf "▅";;
		"5") printf "▆";;
		"6") printf "▇";;
		"7") printf "█";;
		"8") printf "█";;
	esac;
done