aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorDavid Runge <david.runge@native-instruments.de>2018-04-23 08:45:10 +0200
committerDavid Runge <david.runge@native-instruments.de>2018-04-23 08:45:10 +0200
commitb757734a66fc72df4c789fc46ac0553bb2328bcd (patch)
tree8ce275668d008f3f28206ec70a24cbd10659abdf /bin
parent33824987fd7d8764288bcd1814ada49a16a68f15 (diff)
downloaddotfiles-b757734a66fc72df4c789fc46ac0553bb2328bcd.tar.gz
dotfiles-b757734a66fc72df4c789fc46ac0553bb2328bcd.tar.bz2
dotfiles-b757734a66fc72df4c789fc46ac0553bb2328bcd.tar.xz
dotfiles-b757734a66fc72df4c789fc46ac0553bb2328bcd.zip
bin/get_cpu_status: Make script support macOS by using ps).
Diffstat (limited to 'bin')
-rwxr-xr-xbin/get_cpu_status6
1 files changed, 5 insertions, 1 deletions
diff --git a/bin/get_cpu_status b/bin/get_cpu_status
index 18b5c16..d8580db 100755
--- a/bin/get_cpu_status
+++ b/bin/get_cpu_status
@@ -4,7 +4,11 @@ IFS=$'\n\t'
proc_output=""
-proc_output=$(grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$4+$5)} END {printf("%5.1f", usage)}')
+if [ "$(uname)" == "Darwin" ]; then
+ proc_output=$(ps -A -o %cpu | awk '{s+=$1} END {print s}')
+else
+ proc_output=$(grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$4+$5)} END {printf("%5.1f", usage)}')
+fi
proc_output=${proc_output#" "}
echo "$proc_output%"