From 88fbb1f21f67696dcd99e1061cd2873f031df64b Mon Sep 17 00:00:00 2001 From: johnnymatthews <9611008+johnnymatthews@users.noreply.github.com> Date: Sat, 31 Aug 2024 11:48:03 -0300 Subject: [PATCH 1/2] Adds MacOS-specfic `ps aux` command. Potentially closes https://github.com/tmux-plugins/tmux-cpu/issues/89 --- scripts/cpu_percentage.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/cpu_percentage.sh b/scripts/cpu_percentage.sh index 15190f0..f03c3cc 100755 --- a/scripts/cpu_percentage.sh +++ b/scripts/cpu_percentage.sh @@ -28,6 +28,11 @@ print_cpu_percentage() { usage="$(cached_eval WMIC cpu get LoadPercentage | grep -Eo '^[0-9]+')" # shellcheck disable=SC2059 printf "$cpu_percentage_format" "$usage" + else + if is_osx; then + load=$(cached_eval ps aux | awk '{print $3}' | tail -n+2 | awk '{s+=$1} END {print s}') + cpus=$(cpus_number) + echo "$load $cpus" | awk -v format="$cpu_percentage_format" '{printf format, $1/$2}' else load=$(cached_eval ps -aux | awk '{print $3}' | tail -n+2 | awk '{s+=$1} END {print s}') cpus=$(cpus_number) From d11d0b6c7ab423d88873e00c3f987e7e40f72e0d Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Sun, 6 Oct 2024 20:53:57 +0100 Subject: [PATCH 2/2] ps -aux => ps aux --- README.md | 2 +- scripts/cpu_percentage.sh | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/README.md b/README.md index 51f627c..db29585 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ If format strings are added to `status-right`, they should now be visible. ### Optional requirements (Linux, BSD, OSX) - `iostat` or `sar` are the best way to get an accurate CPU percentage. -A fallback is included using `ps -aux` but could be inaccurate. +A fallback is included using `ps aux` but could be inaccurate. - `free` is used for obtaining system RAM status. - `lm-sensors` is used for CPU temperature. - `nvidia-smi` is required for GPU information. diff --git a/scripts/cpu_percentage.sh b/scripts/cpu_percentage.sh index f03c3cc..5e6efe0 100755 --- a/scripts/cpu_percentage.sh +++ b/scripts/cpu_percentage.sh @@ -29,14 +29,9 @@ print_cpu_percentage() { # shellcheck disable=SC2059 printf "$cpu_percentage_format" "$usage" else - if is_osx; then load=$(cached_eval ps aux | awk '{print $3}' | tail -n+2 | awk '{s+=$1} END {print s}') cpus=$(cpus_number) echo "$load $cpus" | awk -v format="$cpu_percentage_format" '{printf format, $1/$2}' - else - load=$(cached_eval ps -aux | awk '{print $3}' | tail -n+2 | awk '{s+=$1} END {print s}') - cpus=$(cpus_number) - echo "$load $cpus" | awk -v format="$cpu_percentage_format" '{printf format, $1/$2}' fi fi }