summaryrefslogblamecommitdiff
path: root/i3blocks-cpuload.sh
blob: dd303114cc6ca50f3bdefb8ddb3ea83d1effda3c (plain) (tree)
1
2
3
4
5
6
7
8
9
         

       



              
                              
                                          

                                                                                    


                                                               


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

cpu_count=$(sysctl -n hw.ncpu)
avg_load=$(sysctl vm.loadavg | cut -w -f3)
percent=$(echo "result = $avg_load / $cpu_count * 100; scale=0; result / 1" | bc -l)

mhz=$(sysctl -n dev.cpu.0.freq)
ghz=$(echo "result = $mhz / 1000; scale=1; result / 1" | bc -l)

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