From de55dc6e6aa28589edbc8a06370225326e31ae8a Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Sat, 16 Jan 2016 18:57:30 +0100 Subject: [PATCH] added a percentage style to the battery indicator --- .tmux.conf | 20 +++++++++++++------- .tmux.conf.local | 6 ++++++ README.md | 8 ++++++++ 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/.tmux.conf b/.tmux.conf index c9f36e7..27a8a6f 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -275,7 +275,7 @@ run 'cut -c3- ~/.tmux.conf | sh -s apply_configuration' # status_right_prefix="#{?client_prefix,#[fg=$tmux_conf_theme_prefix_fg]#[bg=$tmux_conf_theme_prefix_bg]#[bold]⌨ #[fg=$tmux_conf_theme_prefix_fg]#[bg=$tmux_conf_theme_status_bg]#[nobold],}" # fi # if [ x"$battery_enabled" = x"true" ] ; then -# status_right_battery="${tmux_conf_battery:-#(cut -c3- ~/.tmux.conf | sh -s battery ${tmux_conf_battery_symbol:-block} ${tmux_conf_battery_symbol_count:-auto} \"${tmux_conf_battery_palette:-colour160,colour254,colour16}\" ${tmux_conf_battery_status:-enabled})} " +# status_right_battery="${tmux_conf_battery:-#(cut -c3- ~/.tmux.conf | sh -s battery ${tmux_conf_battery_style:-bar} ${tmux_conf_battery_symbol:-block} ${tmux_conf_battery_symbol_count:-auto} \"${tmux_conf_battery_palette:-colour160,colour254,colour16}\" ${tmux_conf_battery_status:-enabled})} " # has_battery=$(eval echo \$${status_right_battery#\#}) # if [ -n "$has_battery" ] && ([ x"$time_enabled" = x"true" ] || [ x"$date_enabled" = x"true" ]) ; then # status_right_battery="${status_right_battery}#[fg=$tmux_conf_theme_time_date_fg,nobold]$right_separator" @@ -410,10 +410,11 @@ run 'cut -c3- ~/.tmux.conf | sh -s apply_configuration' # return # fi # -# battery_symbol=$1 -# battery_symbol_count=$2 -# battery_palette=$3 -# battery_status=$4 +# battery_style=$1 +# battery_symbol=$2 +# battery_symbol_count=$3 +# battery_palette=$4 +# battery_status=$5 # if [ x"$battery_symbol_count" = x"auto" ]; then # columns=$(tmux -q display -p '#{client_width}' 2> /dev/null || echo 80) # if [ $columns -ge 80 ]; then @@ -437,13 +438,18 @@ run 'cut -c3- ~/.tmux.conf | sh -s apply_configuration' # fi # fi # +# if [ x"$battery_style" = x"percentage" ] ; then +# printf %.0f%% $(awk "BEGIN{print $charge * 100}") +# return +# fi +# # if echo $battery_palette | grep -q -E '^heat|gradient(,[a-z0-9]{7,9})?$'; then -# battery_style=$(echo $battery_palette | cut -d, -f1) +# palette_style=$(echo $battery_palette | cut -d, -f1) # battery_bg=$(echo $battery_palette | cut -s -d, -f2) # battery_bg=${battery_bg:-colour16} # gradient="196 202 208 214 220 226 190 154 118 82 46" # heat="233 234 235 237 239 241 243 245 247 144 143 142 184 214 208 202 196" -# eval palette=$(echo \$$battery_style) +# eval palette=$(echo \$$palette_style) # count=$(echo $(echo $palette | wc -w)) # # eval set -- "$palette" diff --git a/.tmux.conf.local b/.tmux.conf.local index ae7ed98..4d26087 100644 --- a/.tmux.conf.local +++ b/.tmux.conf.local @@ -17,6 +17,12 @@ tmux_conf_theme_prefix=disabled tmux_conf_theme_battery=enabled #tmux_conf_theme_battery=disabled +# style to use for the battery status, possible values are: +# - bar +# - percentage +tmux_conf_battery_style=bar +#tmux_conf_battery_style=percentage + # symbols to use for battery status, possible values are: # - block # - heart diff --git a/README.md b/README.md index ef3abd0..fe92bea 100644 --- a/README.md +++ b/README.md @@ -179,6 +179,14 @@ To enable or disable the battery indicator, edit the `~/.tmux.conf.local` file The possible values for `tmux_conf_theme_battery` are `enabled` (default) or `disabled`. +The battery indicator can either be a charging bar or a percentage which is +controlled by the `tmux_conf_battery_style` variable: + + tmux_conf_battery_style=bar + +The possible values for `tmux_conf_battery_style` are `bar` (default) or +`percentage`. + You can also customize the symbol used in the battery bar as well as their number by adjusting the `tmux_conf_battery_symbol` and `tmux_conf_battery_symbol_count` variables.