2021-12-31 05:21:12 +00:00

17 lines
394 B
Bash
Executable File

#!/usr/bin/env bash
cpu() {
icon=" "
read -r cpu a b c previdle rest < /proc/stat
prevtotal=$((a+b+c+previdle))
sleep 0.5
read -r cpu a b c idle rest < /proc/stat
total=$((a+b+c+idle))
cpu=$((100*( (total-prevtotal) - (idle-previdle) ) / (total-prevtotal) ))
cpu=" $cpu%"
printf " %s %s \n" "^c#1e222a^^b#745737^$icon" "^c#1e222a^^b#ffb86c^$cpu"
}
cpu