From 3d5a3cbb8f1a843ae49aba5f0678690cbfc57d6e Mon Sep 17 00:00:00 2001 From: Ethan Edwards Date: Wed, 3 Jun 2020 23:44:17 -0400 Subject: [PATCH] Added ram percentage support --- INSTALL.md | 1 + scripts/dracula.sh | 9 +++++++++ scripts/ram_info.sh | 28 ++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+) create mode 100755 scripts/ram_info.sh diff --git a/INSTALL.md b/INSTALL.md index 3dd0106..24667b1 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -25,3 +25,4 @@ Customize the status bar by adding any of these lines to your .tmux.conf as desi * 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-percent true` +* Enable ram percentage: `set -g @dracula-ram-percent true` diff --git a/scripts/dracula.sh b/scripts/dracula.sh index e3b3bbe..cc2c882 100755 --- a/scripts/dracula.sh +++ b/scripts/dracula.sh @@ -28,6 +28,7 @@ main() show_right_sep=$(get_tmux_option "@dracula-show-right-sep" ) show_border_contrast=$(get_tmux_option "@dracula-border-contrast" false) show_cpu_percentage=$(get_tmux_option "@dracula-cpu-percent" false) + show_ram_percentage=$(get_tmux_option "@dracula-ram-percent" false) # Dracula Color Pallette white='#f8f8f2' @@ -103,6 +104,11 @@ main() powerbg=${pink} fi + if $show_ram_percent; then + tmux set-option -ga status-right "#[fg=${cyan},bg=${powerbg},nobold,nounderscore,noitalics] ${right_sep}#[fg=${dark_gray},bg=${cyan}] #($current_dir/ram_info.sh)" + powerbg=${cyan} + fi + if $show_cpu_percentage; then tmux set-option -ga status-right "#[fg=${orange},bg=${powerbg},nobold,nounderscore,noitalics] ${right_sep}#[fg=${dark_gray},bg=${orange}] #($current_dir/cpu_info.sh)" powerbg=${orange} @@ -135,6 +141,9 @@ main() if $show_battery; then # battery tmux set-option -g status-right "#[fg=${dark_gray},bg=${pink}] #($current_dir/battery.sh) " fi + if $show_ram_percentage; then + tmux set-option -ga status-right "#[fg=${dark_gray},bg=${cyan}] #($current_dir/ram_info.sh) " + fi if $show_cpu_percentage; then tmux set-option -ga status-right "#[fg=${dark_gray},bg=${orange}] #($current_dir/cpu_info.sh) " diff --git a/scripts/ram_info.sh b/scripts/ram_info.sh new file mode 100755 index 0000000..3130e75 --- /dev/null +++ b/scripts/ram_info.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +get_percent() +{ + case $(uname -s) in + Linux) + percent=$(free -m | awk 'NR==2{printf "%.1f%%\n", $3*100/$2}') + echo $percent + ;; + + Darwin) + # TODO - Mac compatability + ;; + + CYGWIN*|MINGW32*|MSYS*|MINGW*) + # TODO - windows compatability + ;; + esac +} + +main() +{ + ram_percent=$(get_percent) + echo "RAM $ram_percent" + sleep 10 +} +#run main driver +main