aboutsummaryrefslogtreecommitdiff
path: root/lemonblocks/modules/cpu_load.sh
blob: 1a677a96a45339131b6f2d26ee2acb0c4174f31f (plain)
1
2
3
4
5
6
7
8
9
10
#!/bin/bash

read cpu a b c previdle rest < /proc/stat
prevtotal=$((a+b+c+previdle))
sleep 0.5
read cpu a b c idle rest < /proc/stat
total=$((a+b+c+idle))
cpu=$((100*( (total-prevtotal) - (idle-previdle) ) / (total-prevtotal) ))

printf " CPU:%s%% " $cpu