dotfiles/.local/scripts/status/0030_0_cpu

11 lines
312 B
Plaintext
Raw Normal View History

2022-08-19 18:02:28 +08:00
#!/bin/bash
COLOR1="#990057"
COLOR2="#FF00B2"
2023-03-02 17:37:56 +08:00
load1="$(grep 'cpu ' /proc/stat)"
load2="$(sleep 1 && grep 'cpu ' /proc/stat)"
usage=$(echo "$load1 \n $load2" | awk -v RS="" '{print ($13-$2+$15-$4)*100/($13-$2+$15-$4+$16-$5)}' | cut -d'.' -f1)"%"
2022-08-19 18:02:28 +08:00
echo "^c$COLOR1^^b$COLOR2^  ^b$COLOR1^^c$COLOR2^ $usage ^d^"