Files
dotfiles/.scripts/dwmblocks/cpu
2026-01-05 10:57:27 +04:00

12 lines
376 B
Bash
Executable File

#!/bin/env bash
colors_path=$HOME/.cache/wal/colors.sh
cpu_usage=$(top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1"%"}')
# cpu_usage=$(echo "$cpu_usage" | cut -c1-1)
cpu_usage=$(printf "%.0f" "$cpu_usage")
if [ -f "$colors_path" ]; then
source $colors_path
echo "^b$color1^^c$color0^  ^d^^b$color8^^c$color0^ $cpu_usage% ^d^"
fi