SketchyBar/plugins/cpu_graph.sh
2021-08-14 13:16:50 +02:00

12 lines
436 B
Bash
Executable file

#!/usr/bin/env bash
CORE_COUNT=$(sysctl -n machdep.cpu.thread_count)
CPU_INFO=$(ps -eo pcpu,user)
CPU_SYS=$(echo "$CPU_INFO" | grep -v $(whoami) | sed "s/[^ 0-9\.]//g" | awk "{sum+=\$1} END {print sum/(100.0 * $CORE_COUNT)}")
CPU_USER=$(echo "$CPU_INFO" | grep $(whoami) | sed "s/[^ 0-9\.]//g" | awk "{sum+=\$1} END {print sum/(100.0 * $CORE_COUNT)}")
sketchybar -m push cpu_sys 0 $CPU_SYS
sketchybar -m push cpu_user 0 $CPU_USER