Added ram percentage support

This commit is contained in:
Ethan Edwards 2020-06-03 23:44:17 -04:00
parent caa43a91ae
commit 3d5a3cbb8f
3 changed files with 38 additions and 0 deletions

View file

@ -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`

View file

@ -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) "

28
scripts/ram_info.sh Executable file
View file

@ -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