mirror of
https://github.com/tmux-plugins/tmux-cpu.git
synced 2026-09-10 07:16:16 -04:00
gpu_percentage
This commit is contained in:
parent
12f7a74e25
commit
c778fe3521
2
cpu.tmux
2
cpu.tmux
|
|
@ -9,12 +9,14 @@ cpu_interpolation=(
|
|||
"\#{cpu_icon}"
|
||||
"\#{cpu_bg_color}"
|
||||
"\#{cpu_fg_color}"
|
||||
"\#{gpu_percentage}"
|
||||
)
|
||||
cpu_commands=(
|
||||
"#($CURRENT_DIR/scripts/cpu_percentage.sh)"
|
||||
"#($CURRENT_DIR/scripts/cpu_icon.sh)"
|
||||
"#($CURRENT_DIR/scripts/cpu_bg_color.sh)"
|
||||
"#($CURRENT_DIR/scripts/cpu_fg_color.sh)"
|
||||
"#($CURRENT_DIR/scripts/gpu_percentage.sh)"
|
||||
)
|
||||
|
||||
set_tmux_option() {
|
||||
|
|
|
|||
21
scripts/gpu_percentage.sh
Executable file
21
scripts/gpu_percentage.sh
Executable file
|
|
@ -0,0 +1,21 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
source "$CURRENT_DIR/helpers.sh"
|
||||
|
||||
print_gpu_percentage() {
|
||||
if command_exists "nvidia-smi"; then
|
||||
loads=$(nvidia-smi | sed -nr 's/.*\s([0-9]+)%.*/\1/p')
|
||||
gpus=$(echo "$loads" | wc -l)
|
||||
load=$(echo "$loads" | awk '{count+=$1} END {print count}')
|
||||
echo "$load $gpus" | awk '{printf "%2.0f%%", $1/$2}'
|
||||
else
|
||||
echo "nvidia-smi not found"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
print_gpu_percentage
|
||||
}
|
||||
main
|
||||
Loading…
Reference in a new issue