1
0
Fork 0
mirror of synced 2024-12-21 22:31:06 -05:00

optimized _apply_theme() to launch background jobs straight from _apply_configuration()

tmux doesn't share jobs between clients, and when multiple clients are attached
the _load_avg(), _uptime() and _battery_bar() jobs get spawned once per client
attached, which is wasteful
This commit is contained in:
Gregory Pakosz 2019-12-20 18:22:19 +01:00
parent 22de553361
commit eae2cf27fb

View file

@ -188,9 +188,6 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim
# fi
# fi
#
# __newline='
# '
#
# _uname_s=$(uname -s)
#
# _is_enabled() {
@ -350,25 +347,12 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim
# return
# fi
#
# variables=$(tmux show -gqv '@battery_bar_symbol_full' \;\
# show -gqv '@battery_bar_symbol_empty' \;\
# show -gqv '@battery_bar_length' \;\
# show -gqv '@battery_bar_palette' \;\
# show -gqv '@battery_hbar_palette' \;\
# show -gqv '@battery_vbar_palette' \;\
# show -gqv '@battery_status_charging' \;\
# show -gqv '@battery_status_discharging')
# # shellcheck disable=SC2086
# { set -f; IFS="$__newline"; set -- $variables; unset IFS; set +f; }
#
# battery_bar_symbol_full=$1
# battery_bar_symbol_empty=$2
# battery_bar_length=$3
# battery_bar_palette=$4
# battery_hbar_palette=$5
# battery_vbar_palette=$6
# battery_status_charging=$7
# battery_status_discharging=$8
#
# if [ x"$battery_bar_length" = x"auto" ]; then
# columns=$(tmux -q display -p '#{client_width}' 2> /dev/null || echo 80)
@ -379,12 +363,6 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim
# fi
# fi
#
# if [ x"$discharging" = x"true" ]; then
# battery_status="$battery_status_discharging"
# else
# battery_status="$battery_status_charging"
# fi
#
# if echo "$battery_bar_palette" | grep -q -E '^heat|gradient(,[#a-z0-9]{7,9})?$'; then
# # shellcheck disable=SC2086
# { set -f; IFS=,; set -- $battery_bar_palette; unset IFS; set +f; }
@ -1092,14 +1070,14 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim
#
# # -- variables
#
# tmux_conf_battery_bar_symbol_full=${tmux_conf_battery_bar_symbol_full:-◼}
# tmux_conf_battery_bar_symbol_empty=${tmux_conf_battery_bar_symbol_empty:-◻}
# tmux_conf_battery_bar_symbol_full=$(_decode_unicode_escapes "${tmux_conf_battery_bar_symbol_full:-◼}")
# tmux_conf_battery_bar_symbol_empty=$(_decode_unicode_escapes "${tmux_conf_battery_bar_symbol_empty:-◻}")
# tmux_conf_battery_bar_length=${tmux_conf_battery_bar_length:-auto}
# tmux_conf_battery_bar_palette=${tmux_conf_battery_bar_palette:-gradient}
# tmux_conf_battery_hbar_palette=${tmux_conf_battery_hbar_palette:-gradient} # red, orange, green
# tmux_conf_battery_vbar_palette=${tmux_conf_battery_vbar_palette:-gradient} # red, orange, green
# tmux_conf_battery_status_charging=${tmux_conf_battery_status_charging:-↑} # U+2191
# tmux_conf_battery_status_discharging=${tmux_conf_battery_status_discharging:-↓} # U+2193
# tmux_conf_battery_hbar_palette=${tmux_conf_battery_hbar_palette:-gradient} # red, orange, green
# tmux_conf_battery_vbar_palette=${tmux_conf_battery_vbar_palette:-gradient} # red, orange, green
# tmux_conf_battery_status_charging=$(_decode_unicode_escapes "${tmux_conf_battery_status_charging:-↑}") # U+2191
# tmux_conf_battery_status_discharging=$(_decode_unicode_escapes "${tmux_conf_battery_status_discharging:-↓}") # U+2193
#
# case "$status_left $status_right" in
# *'#{battery_status}'*|*'#{battery_bar}'*|*'#{battery_hbar}'*|*'#{battery_vbar}'*|*'#{battery_percentage}'*)
@ -1116,8 +1094,9 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim
# -e 's/#\{(\?)?battery_status/#\{\1@battery_status/g' \
# -e 's/#\{(\?)?battery_percentage/#\{\1@battery_percentage/g')
# interval=60
# pkill -f 'cut -c3- ~/\.tmux\.conf \| sh -s _battery' || true
# status_right="#(printf '\n'; nice cut -c3- ~/.tmux.conf | sh -s _battery_status \"$tmux_conf_battery_status_charging\" \"$tmux_conf_battery_status_discharging\")#(printf '\n'; while [ \$(tmux display -p '##{session_attached}') -gt 0 ]; do nice cut -c3- ~/.tmux.conf | sh -s _battery_bar; sleep $interval; done)$status_right"
# pkill -f 'cut -c3- ~/\.tmux\.conf \| sh -s _battery_bar' || true
# 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
#
@ -1159,7 +1138,7 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim
# ;;
# esac
# pkill -f 'cut -c3- ~/\.tmux\.conf \| sh -s _uptime' || true
# status_right="#(printf '\n'; while [ \$(tmux display -p '##{session_attached}') -gt 0 ]; do nice cut -c3- ~/.tmux.conf | sh -s _uptime; sleep $interval; done)$status_right"
# tmux run -b "trap 'exit 0' TERM; while :; do nice cut -c3- ~/.tmux.conf | sh -s _uptime; sleep $interval; done"
# ;;
# esac
#
@ -1171,7 +1150,7 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim
# -e 's/#\{(\?)?loadavg/#\{\1@loadavg/g')
# interval=$(tmux show -gv status-interval)
# pkill -f 'cut -c3- ~/\.tmux\.conf \| sh -s _loadavg' || true
# status_right="#(printf '\n'; while [ \$(tmux display -p '##{session_attached}') -gt 0 ]; do nice cut -c3- ~/.tmux.conf | sh -s _loadavg; sleep $interval; done)$status_right"
# tmux run -b "trap 'exit 0' TERM; while :; do nice cut -c3- ~/.tmux.conf | sh -s _loadavg; sleep $interval; done"
# ;;
# esac
#
@ -1197,12 +1176,6 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim
# setw -g window-status-activity-style "fg=$tmux_conf_theme_window_status_activity_fg,bg=$tmux_conf_theme_window_status_activity_bg,$tmux_conf_theme_window_status_activity_attr" \;\
# setw -g window-status-bell-style "fg=$tmux_conf_theme_window_status_bell_fg,bg=$tmux_conf_theme_window_status_bell_bg,$tmux_conf_theme_window_status_bell_attr" \;\
# setw -g window-status-last-style "fg=$tmux_conf_theme_window_status_last_fg,bg=$tmux_conf_theme_window_status_last_bg,$tmux_conf_theme_window_status_last_attr" \;\
# set -g '@battery_bar_symbol_full' "$(_decode_unicode_escapes "$tmux_conf_battery_bar_symbol_full")" \;\
# set -g '@battery_bar_symbol_empty' "$(_decode_unicode_escapes "$tmux_conf_battery_bar_symbol_empty")" \;\
# set -g '@battery_bar_length' "$tmux_conf_battery_bar_length" \;\
# set -g '@battery_bar_palette' "$tmux_conf_battery_bar_palette" \;\
# set -g '@battery_hbar_palette' "$tmux_conf_battery_hbar_palette" \;\
# set -g '@battery_vbar_palette' "$tmux_conf_battery_vbar_palette" \;\
# set -g status-left-length 1000 \; set -g status-left "$(_decode_unicode_escapes "$status_left")" \;\
# set -g status-right-length 1000 \; set -g status-right "$(_decode_unicode_escapes "$status_right")" \;\
# setw -g clock-mode-colour "$tmux_conf_theme_clock_colour" \;\