TheRepoClub-DotFiles/flexiflow_bar/.local/bin/flexiflow_bar/bar_cpu
2023-08-15 17:37:16 +01:00

20 lines
472 B
Bash
Executable File

#!/usr/bin/env bash
cpu() {
# load colors
. $HOME/.config/flexiflow_bar/bar_themes/minimal-mistakes
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)))
printf " %s %s \n" "^c$Foreground^^b$Orange^$icon" "^c$Foreground^^b$Orange_Bright^ $cpu%"
}
cpu