Files
dotfiles/waybar/modules/cpu.sh
2022-08-07 19:47:29 +02:00

9 lines
241 B
Bash

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