Merge pull request #50 from ethancedwards8/master

Adding GPU usage.
This commit is contained in:
Dane Williams 2020-07-05 10:39:57 -07:00 committed by GitHub
commit 60c2017fb0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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`
* 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 cpu percentage: `set -g @dracula-cpu-usage true`
* Enable ram percentage: `set -g @dracula-ram-usage true`
* Enable cpu usage: `set -g @dracula-cpu-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
* CPU usage
* RAM usage
* GPU usage
* Color code based on if prefix is active or not
* List of windows with current window highlighted
* 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_cpu_usage=$(get_tmux_option "@dracula-cpu-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
white='#f8f8f2'
@ -114,6 +115,11 @@ main()
powerbg=${orange}
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
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}
@ -149,6 +155,10 @@ main()
tmux set-option -ga status-right "#[fg=${dark_gray},bg=${orange}] #($current_dir/cpu_info.sh) "
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
tmux set-option -ga status-right "#[fg=${dark_gray},bg=${cyan}] #($current_dir/network.sh) "
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