From 98c74671949d11b61ae519e4dd9a1dd70d6440e8 Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Mon, 17 Feb 2020 20:20:19 +0100 Subject: [PATCH] launch _battery_bar() background job only if a battery is present --- .tmux.conf | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/.tmux.conf b/.tmux.conf index 2b09b13..567db7f 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -1080,25 +1080,28 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # tmux_conf_battery_status_discharging=$(_decode_unicode_escapes "${tmux_conf_battery_status_discharging:-↓}") # U+2193 # # pkill -f 'cut -c3- ~/\.tmux\.conf \| sh -s _battery_bar' || true -# case "$status_left $status_right" in -# *'#{battery_status}'*|*'#{battery_bar}'*|*'#{battery_hbar}'*|*'#{battery_vbar}'*|*'#{battery_percentage}'*) -# status_left=$(echo "$status_left" | sed -E \ -# -e 's/#\{(\?)?battery_bar/#\{\1@battery_bar/g' \ -# -e 's/#\{(\?)?battery_hbar/#\{\1@battery_hbar/g' \ -# -e 's/#\{(\?)?battery_vbar/#\{\1@battery_vbar/g' \ -# -e 's/#\{(\?)?battery_status/#\{\1@battery_status/g' \ -# -e 's/#\{(\?)?battery_percentage/#\{\1@battery_percentage/g') -# status_right=$(echo "$status_right" | sed -E \ -# -e 's/#\{(\?)?battery_bar/#\{\1@battery_bar/g' \ -# -e 's/#\{(\?)?battery_hbar/#\{\1@battery_hbar/g' \ -# -e 's/#\{(\?)?battery_vbar/#\{\1@battery_vbar/g' \ -# -e 's/#\{(\?)?battery_status/#\{\1@battery_status/g' \ -# -e 's/#\{(\?)?battery_percentage/#\{\1@battery_percentage/g') -# interval=60 -# tmux run -b "trap 'exit 0' TERM; while :; do nice cut -c3- ~/.tmux.conf | sh -s _battery_bar \"$tmux_conf_battery_bar_symbol_full\" \"$tmux_conf_battery_bar_symbol_empty\" \"$tmux_conf_battery_bar_length\" \"$tmux_conf_battery_bar_palette\" \"$tmux_conf_battery_hbar_palette\" \"$tmux_conf_battery_vbar_palette\"; sleep $interval; done" -# status_right="#(printf '\n'; nice cut -c3- ~/.tmux.conf | sh -s _battery_status \"$tmux_conf_battery_status_charging\" \"$tmux_conf_battery_status_discharging\")$status_right" -# ;; -# esac +# _battery_info +# if [ "$charge" != 0 ]; then +# case "$status_left $status_right" in +# *'#{battery_status}'*|*'#{battery_bar}'*|*'#{battery_hbar}'*|*'#{battery_vbar}'*|*'#{battery_percentage}'*) +# status_left=$(echo "$status_left" | sed -E \ +# -e 's/#\{(\?)?battery_bar/#\{\1@battery_bar/g' \ +# -e 's/#\{(\?)?battery_hbar/#\{\1@battery_hbar/g' \ +# -e 's/#\{(\?)?battery_vbar/#\{\1@battery_vbar/g' \ +# -e 's/#\{(\?)?battery_status/#\{\1@battery_status/g' \ +# -e 's/#\{(\?)?battery_percentage/#\{\1@battery_percentage/g') +# status_right=$(echo "$status_right" | sed -E \ +# -e 's/#\{(\?)?battery_bar/#\{\1@battery_bar/g' \ +# -e 's/#\{(\?)?battery_hbar/#\{\1@battery_hbar/g' \ +# -e 's/#\{(\?)?battery_vbar/#\{\1@battery_vbar/g' \ +# -e 's/#\{(\?)?battery_status/#\{\1@battery_status/g' \ +# -e 's/#\{(\?)?battery_percentage/#\{\1@battery_percentage/g') +# interval=60 +# tmux run -b "trap 'exit 0' TERM; while :; do nice cut -c3- ~/.tmux.conf | sh -s _battery_bar \"$tmux_conf_battery_bar_symbol_full\" \"$tmux_conf_battery_bar_symbol_empty\" \"$tmux_conf_battery_bar_length\" \"$tmux_conf_battery_bar_palette\" \"$tmux_conf_battery_hbar_palette\" \"$tmux_conf_battery_vbar_palette\"; sleep $interval; done" +# status_right="#(printf '\n'; nice cut -c3- ~/.tmux.conf | sh -s _battery_status \"$tmux_conf_battery_status_charging\" \"$tmux_conf_battery_status_discharging\")$status_right" +# ;; +# esac +# fi # # case "$status_left $status_right" in # *'#{username}'*|*'#{hostname}'*|*'#{username_ssh}'*|*'#{hostname_ssh}'*)