added gpu usage

This commit is contained in:
Ethan Edwards 2020-06-29 22:44:51 -04:00
parent a68dcc7d88
commit dcb6f48a4d
4 changed files with 51 additions and 2 deletions

View file

@ -24,5 +24,6 @@ Customize the status bar by adding any of these lines to your .tmux.conf as desi
* Enable military time: `set -g @dracula-military-time true` * Enable military time: `set -g @dracula-military-time true`
* Switch the left smiley icon `set -g @dracula-show-left-icon session` it can accept `session`, `smiley`, `window`, or any character. * Switch the left smiley icon `set -g @dracula-show-left-icon session` it can accept `session`, `smiley`, `window`, or any character.
* Enable high contrast pane border: `set -g @dracula-border-contrast true` * Enable high contrast pane border: `set -g @dracula-border-contrast true`
* Enable cpu percentage: `set -g @dracula-cpu-usage true` * Enable cpu usage: `set -g @dracula-cpu-usage true`
* Enable ram percentage: `set -g @dracula-ram-usage true` * Enable ram usage: `set -g @dracula-ram-usage true`
* Enable gpu usage: `set -g @dracula-gpu-usage true`

View file

@ -21,6 +21,7 @@ Configuration and options can be found at [draculatheme.com/tmux](https://dracul
* Battery percentage and AC power connection status * Battery percentage and AC power connection status
* CPU usage * CPU usage
* RAM usage * RAM usage
* GPU usage
* Color code based on if prefix is active or not * Color code based on if prefix is active or not
* List of windows with current window highlighted * List of windows with current window highlighted
* When prefix is enabled smiley face turns from green to yellow * When prefix is enabled smiley face turns from green to yellow

View file

@ -29,6 +29,7 @@ main()
show_border_contrast=$(get_tmux_option "@dracula-border-contrast" false) show_border_contrast=$(get_tmux_option "@dracula-border-contrast" false)
show_cpu_usage=$(get_tmux_option "@dracula-cpu-usage" false) show_cpu_usage=$(get_tmux_option "@dracula-cpu-usage" false)
show_ram_usage=$(get_tmux_option "@dracula-ram-usage" false) show_ram_usage=$(get_tmux_option "@dracula-ram-usage" false)
show_gpu_usage=$(get_tmux_option "@dracula-gpu-usage" false)
# Dracula Color Pallette # Dracula Color Pallette
white='#f8f8f2' white='#f8f8f2'
@ -114,6 +115,11 @@ main()
powerbg=${orange} powerbg=${orange}
fi fi
if $show_gpu_usage; then
tmux set-option -ga status-right "#[fg=${pink},bg=${powerbg},nobold,nounderscore,noitalics] ${right_sep}#[fg=${dark_gray},bg=${pink}] #($current_dir/gpu_usage.sh)"
powerbg=${pink}
fi
if $show_network; then # network if $show_network; then # network
tmux set-option -ga status-right "#[fg=${cyan},bg=${powerbg},nobold,nounderscore,noitalics] ${right_sep}#[fg=${dark_gray},bg=${cyan}] #($current_dir/network.sh)" tmux set-option -ga status-right "#[fg=${cyan},bg=${powerbg},nobold,nounderscore,noitalics] ${right_sep}#[fg=${dark_gray},bg=${cyan}] #($current_dir/network.sh)"
powerbg=${cyan} powerbg=${cyan}
@ -149,6 +155,10 @@ main()
tmux set-option -ga status-right "#[fg=${dark_gray},bg=${orange}] #($current_dir/cpu_info.sh) " tmux set-option -ga status-right "#[fg=${dark_gray},bg=${orange}] #($current_dir/cpu_info.sh) "
fi fi
if $show_gpu_usage; then
tmux set-option -ga status-right "#[fg=${dark_gray},bg=${pink}] #($current_dir/gpu_usage.sh) "
fi
if $show_network; then # network if $show_network; then # network
tmux set-option -ga status-right "#[fg=${dark_gray},bg=${cyan}] #($current_dir/network.sh) " tmux set-option -ga status-right "#[fg=${dark_gray},bg=${cyan}] #($current_dir/network.sh) "
fi fi

37
scripts/gpu_usage.sh Executable file
View file

@ -0,0 +1,37 @@
#!/usr/bin/env bash
get_platform()
{
case $(uname -s) in
Linux)
gpu=$(lspci -v | grep -i gpu | grep driver | awk '{print $5}')
echo $gpu
;;
Darwin)
# TODO - Darwin/Mac compatability
;;
CYGWIN*|MINGW32*|MSYS*|MINGW*)
# TODO - windows compatability
;;
esac
}
get_gpu()
{
gpu=$(get_platform)
if [ $gpu == nvidia-gpu ]; then
usage=$(nvidia-smi | grep "%" | awk '{print $13}')
echo $usage
fi
}
main()
{
gpu_usage=$(get_gpu)
echo "GPU $gpu_usage"
sleep 10
}
# run the main driver
main