summaryrefslogblamecommitdiff
path: root/i3blocks-cpuload.sh
blob: 6d3773f764e4e59a6d5646af77834abab4c6b2c4 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
















                                                                                    
#!/bin/sh
cpu_count=4
low=25
high=75
icon=󰻠
icon_low=󰒲
icon_mid=󰜎
icon_high=󱅝

avg_load=$(uptime | cut -d, -f4 | cut -d: -f2)
percent=$(echo "result = $avg_load / $cpu_count * 100; scale=0; result / 1" | bc -l)

printf $icon
[ $percent -lt $low ] && printf $icon_low
[ $percent -ge $low ] && [ $percent -lt $high ] && printf $icon_mid
[ $percent -ge $high ] && printf $icon_high
printf " %s%%\n" $percent