From dcb6f48a4d40a44593f483d8283742e07768658f Mon Sep 17 00:00:00 2001 From: Ethan Edwards Date: Mon, 29 Jun 2020 22:44:51 -0400 Subject: [PATCH] added gpu usage --- INSTALL.md | 5 +++-- README.md | 1 + scripts/dracula.sh | 10 ++++++++++ scripts/gpu_usage.sh | 37 +++++++++++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 2 deletions(-) create mode 100755 scripts/gpu_usage.sh diff --git a/INSTALL.md b/INSTALL.md index abd5055..e4550bf 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -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` diff --git a/README.md b/README.md index b76073d..f8ec8a9 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/scripts/dracula.sh b/scripts/dracula.sh index 04911f5..7843d3d 100755 --- a/scripts/dracula.sh +++ b/scripts/dracula.sh @@ -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 diff --git a/scripts/gpu_usage.sh b/scripts/gpu_usage.sh new file mode 100755 index 0000000..3bb1445 --- /dev/null +++ b/scripts/gpu_usage.sh @@ -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 + +