From 81b6897294c74a6695b68e91b9d4d2ab81f2a605 Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Mon, 14 Sep 2015 21:17:06 +0200 Subject: [PATCH] pimped the battery indicator with a gradient palette --- .tmux.conf | 15 +++++++++------ .tmux.conf.local | 2 ++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.tmux.conf b/.tmux.conf index 10d0e86..ca5316b 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -380,19 +380,22 @@ run 'for name in $(printenv | grep -Eo ^tmux_conf_[^=]+); do tmux setenv -gu $na # [ $empty -gt 0 ] && \ # printf '#[fg=%s,bg=%s]' $battery_empty_fg $battery_bg && \ # printf "%0.s$battery_symbol_empty" $(seq 1 $empty) -# elif echo $battery_palette | grep -q -E '^heat(,colour[0-9]{1,3})?$'; then +# elif echo $battery_palette | grep -q -E '^heat|gradient(,colour[0-9]{1,3})?$'; then +# battery_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" -# heat_count=$(echo $(echo $heat | wc -w)) +# eval palette=$(echo \$$battery_style) +# count=$(echo $(echo $palette | wc -w)) # -# eval set -- "$heat" -# heat=$(eval echo $(eval echo $(printf "\\$\{\$(expr %s \* $heat_count / $battery_symbol_count)\} " $(seq 1 $battery_symbol_count)))) +# eval set -- "$palette" +# palette=$(eval echo $(eval echo $(printf "\\$\{\$(expr %s \* $count / $battery_symbol_count)\} " $(seq 1 $battery_symbol_count)))) # # full=$(printf %.0f $(echo "$charge * $battery_symbol_count" | bc -l)) # printf '#[bg=%s]' $battery_bg # [ $full -gt 0 ] && \ -# printf "#[fg=colour%s]$battery_symbol_full" $(echo $heat | cut -d' ' -f1-$full) +# printf "#[fg=colour%s]$battery_symbol_full" $(echo $palette | cut -d' ' -f1-$full) # empty=$(($battery_symbol_count - $full)) # if [ x"$battery_symbol" = x"heart" ]; then # [ $empty -gt 0 ] && \ @@ -400,7 +403,7 @@ run 'for name in $(printenv | grep -Eo ^tmux_conf_[^=]+); do tmux setenv -gu $na # printf "%0.s$battery_symbol_empty" $(seq 1 $empty) # else # [ $empty -gt 0 ] && \ -# printf "#[fg=colour%s]$battery_symbol_empty" $(echo $heat | cut -d' ' -f$((full+1))-$(($full + $empty))) +# printf "#[fg=colour%s]$battery_symbol_empty" $(echo $palette | cut -d' ' -f$((full+1))-$(($full + $empty))) # fi # fi # } diff --git a/.tmux.conf.local b/.tmux.conf.local index d21254d..f657fe2 100644 --- a/.tmux.conf.local +++ b/.tmux.conf.local @@ -7,6 +7,8 @@ # use the heat palette for the battery status #tmux_conf_battery_palette=heat +# use the gradient palette for the battery status +#tmux_conf_battery_palette=gradient # display the battery status: charging (U+26A1) / discharging (U+1F50B) #tmux_conf_battery_status=true