fixed #{battery_bar} auto width, also resolves #447
This commit is contained in:
parent
1469d465f8
commit
7e00233465
2 changed files with 227 additions and 173 deletions
397
.tmux.conf
397
.tmux.conf
|
@ -258,6 +258,143 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration'
|
|||
# esac
|
||||
# fi
|
||||
#
|
||||
# _bar() {
|
||||
# bar_palette=$1
|
||||
# bar_symbol_empty=$2
|
||||
# bar_symbol_full=$3
|
||||
# bar_length=$4
|
||||
# bar_value=$5
|
||||
#
|
||||
# if [ "$bar_length" = "auto" ]; then
|
||||
# columns=${6:-$(tmux -q display -p '#{client_width}' 2> /dev/null || echo 80)}
|
||||
# if [ "$columns" -ge 160 ]; then
|
||||
# bar_length=12
|
||||
# elif [ "$columns" -ge 130 ]; then
|
||||
# bar_length=10
|
||||
# elif [ "$columns" -ge 120 ]; then
|
||||
# bar_length=8
|
||||
# elif [ "$columns" -ge 100 ]; then
|
||||
# bar_length=6
|
||||
# else
|
||||
# bar_length=4
|
||||
# fi
|
||||
# fi
|
||||
#
|
||||
# if echo "$bar_palette" | grep -q -E '^heat|gradient(,[#a-z0-9]{7,9})?$'; then
|
||||
# # shellcheck disable=SC2086
|
||||
# { set -f; IFS=,; set -- $bar_palette; unset IFS; set +f; }
|
||||
# palette_style=$1
|
||||
# bg=${2:-none}
|
||||
# [ "$palette_style" = "gradient" ] && \
|
||||
# palette="196 202 208 214 220 226 190 154 118 82 46"
|
||||
# [ "$palette_style" = "heat" ] && \
|
||||
# palette="243 245 247 144 143 142 184 214 208 202 196"
|
||||
#
|
||||
# palette=$(echo "$palette" | awk -v n="$bar_length" '{ for (i = 0; i < n; ++i) printf $(1 + (i * NF / n))" " }')
|
||||
# eval set -- "$palette"
|
||||
#
|
||||
# full=$(awk "BEGIN { printf \"%.0f\", ($bar_value) * $bar_length }")
|
||||
# bar="#[bg=$bg]"
|
||||
# # shellcheck disable=SC2046
|
||||
# [ "$full" -gt 0 ] && \
|
||||
# bar="$bar$(printf "#[fg=colour%s]$bar_symbol_full" $(echo "$palette" | cut -d' ' -f1-"$full"))"
|
||||
# # shellcheck disable=SC2046
|
||||
# empty=$((bar_length - full))
|
||||
# # shellcheck disable=SC2046
|
||||
# [ "$empty" -gt 0 ] && \
|
||||
# bar="$bar$(printf "#[fg=colour%s]$bar_symbol_empty" $(echo "$palette" | cut -d' ' -f$((full + 1))-$((full + empty))))"
|
||||
# eval bar="$bar#[fg=colour\${$((full == 0 ? 1 : full))}]"
|
||||
# elif echo "$bar_palette" | grep -q -E '^(([#a-z0-9]{7,9}|none),?){3}$'; then
|
||||
# # shellcheck disable=SC2086
|
||||
# { set -f; IFS=,; set -- $bar_palette; unset IFS; set +f; }
|
||||
# full_fg=$1
|
||||
# empty_fg=$2
|
||||
# bg=$3
|
||||
#
|
||||
# full=$(awk "BEGIN { printf \"%.0f\", ($bar_value) * $bar_length }")
|
||||
# [ "$bg" != "none" ] && \
|
||||
# bar="#[bg=$bg]"
|
||||
# #shellcheck disable=SC2046
|
||||
# [ "$full" -gt 0 ] && \
|
||||
# bar="$bar#[fg=$full_fg]$(printf "%0.s$bar_symbol_full" $(seq 1 "$full"))"
|
||||
# empty=$((bar_length - full))
|
||||
# #shellcheck disable=SC2046
|
||||
# [ "$empty" -gt 0 ] && \
|
||||
# bar="$bar#[fg=$empty_fg]$(printf "%0.s$bar_symbol_empty" $(seq 1 "$empty"))" && \
|
||||
# bar="$bar#[fg=$empty_fg]"
|
||||
# fi
|
||||
#
|
||||
# printf '%s' "$bar"
|
||||
# }
|
||||
#
|
||||
# _hbar() {
|
||||
# hbar_palette=$1
|
||||
# hbar_value=$2
|
||||
#
|
||||
# if echo "$hbar_palette" | grep -q -E '^heat|gradient(,[#a-z0-9]{7,9})?$'; then
|
||||
# # shellcheck disable=SC2086
|
||||
# { set -f; IFS=,; set -- $hbar_palette; unset IFS; set +f; }
|
||||
# palette_style=$1
|
||||
# [ "$palette_style" = "gradient" ] && \
|
||||
# palette="196 202 208 214 220 226 190 154 118 82 46"
|
||||
# [ "$palette_style" = "heat" ] && \
|
||||
# palette="233 234 235 237 239 241 243 245 247 144 143 142 184 214 208 202 196"
|
||||
#
|
||||
# palette=$(echo "$palette" | awk -v n=8 '{ for (i = 0; i < n; ++i) printf $(1 + (i * NF / n))" " }')
|
||||
# eval set -- "$palette"
|
||||
#
|
||||
# full=$(awk "BEGIN { printf \"%.0f\", ($hbar_value) * 8 }")
|
||||
# eval hbar_fg="colour\${$((full == 0 ? 1 : full))}"
|
||||
# elif echo "$hbar_palette" | grep -q -E '^([#a-z0-9]{7,9},?){3}$'; then
|
||||
# # shellcheck disable=SC2086
|
||||
# { set -f; IFS=,; set -- $hbar_palette; unset IFS; set +f; }
|
||||
#
|
||||
# # shellcheck disable=SC2046
|
||||
# eval $(awk "BEGIN { printf \"hbar_fg=$%d\", (($hbar_value) - 0.001) * $# + 1 }")
|
||||
# fi
|
||||
#
|
||||
# eval set -- "▏ ▎ ▍ ▌ ▋ ▊ ▉ █"
|
||||
# # shellcheck disable=SC2046
|
||||
# eval $(awk "BEGIN { printf \"hbar_symbol=$%d\", ($hbar_value) * ($# - 1) + 1 }")
|
||||
# hbar="#[bg=none]#[fg=${hbar_fg?}]${hbar_symbol?}"
|
||||
#
|
||||
# printf '%s' "$hbar"
|
||||
# }
|
||||
#
|
||||
# _vbar() {
|
||||
# vbar_palette=$1
|
||||
# vbar_value=$2
|
||||
#
|
||||
# if echo "$vbar_palette" | grep -q -E '^heat|gradient(,[#a-z0-9]{7,9})?$'; then
|
||||
# # shellcheck disable=SC2086
|
||||
# { set -f; IFS=,; set -- $vbar_palette; unset IFS; set +f; }
|
||||
# palette_style=$1
|
||||
# [ "$palette_style" = "gradient" ] && \
|
||||
# palette="196 202 208 214 220 226 190 154 118 82 46"
|
||||
# [ "$palette_style" = "heat" ] && \
|
||||
# palette="233 234 235 237 239 241 243 245 247 144 143 142 184 214 208 202 196"
|
||||
#
|
||||
# palette=$(echo "$palette" | awk -v n=8 '{ for (i = 0; i < n; ++i) printf $(1 + (i * NF / n))" " }')
|
||||
# eval set -- "$palette"
|
||||
#
|
||||
# full=$(awk "BEGIN { printf \"%.0f\", ($vbar_value) * 8 }")
|
||||
# eval vbar_fg="colour\${$((full == 0 ? 1 : full))}"
|
||||
# elif echo "$vbar_palette" | grep -q -E '^([#a-z0-9]{7,9},?){3}$'; then
|
||||
# # shellcheck disable=SC2086
|
||||
# { set -f; IFS=,; set -- $vbar_palette; unset IFS; set +f; }
|
||||
#
|
||||
# # shellcheck disable=SC2046
|
||||
# eval $(awk "BEGIN { printf \"vbar_fg=$%d\", (($vbar_value) - 0.001) * $# + 1 }")
|
||||
# fi
|
||||
#
|
||||
# eval set -- "▁ ▂ ▃ ▄ ▅ ▆ ▇ █"
|
||||
# # shellcheck disable=SC2046
|
||||
# eval $(awk "BEGIN { printf \"vbar_symbol=$%d\", ($vbar_value) * ($# - 1) + 1 }")
|
||||
# vbar="#[bg=none]#[fg=${vbar_fg?}]${vbar_symbol?}"
|
||||
#
|
||||
# printf '%s' "$vbar"
|
||||
# }
|
||||
#
|
||||
# _maximize_pane() {
|
||||
# current_session=${1:-$(tmux display -p '#{session_name}')}
|
||||
# current_pane=${2:-$(tmux display -p '#{pane_id}')}
|
||||
|
@ -301,16 +438,15 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration'
|
|||
# }
|
||||
#
|
||||
# _battery_info() {
|
||||
# count=0
|
||||
# charge=0
|
||||
# battery_count=0
|
||||
# battery_charge=0
|
||||
# case "$_uname_s" in
|
||||
# *Darwin*)
|
||||
# while IFS= read -r line; do
|
||||
# [ -z "$line" ] && continue
|
||||
# discharging=$(printf '%s' "$line" | grep -qi "discharging" && echo "true" || echo "false")
|
||||
# percentage=$(printf '%s' "$line" | grep -E -o '[0-9]+%' || echo "0%")
|
||||
# charge=$(awk -v charge="$charge" -v percentage="${percentage%%%}" 'BEGIN { print charge + percentage / 100 }')
|
||||
# count=$((count + 1))
|
||||
# battery_charge=$(awk -v charge="$battery_charge" -v percentage="${percentage%%%}" 'BEGIN { print charge + percentage / 100 }')
|
||||
# battery_count=$((battery_count + 1))
|
||||
# done << EOF
|
||||
# $(pmset -g batt | grep 'InternalBattery')
|
||||
# EOF
|
||||
|
@ -320,18 +456,17 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration'
|
|||
# [ -z "$batpath" ] && continue
|
||||
# grep -i -q device "$batpath/scope" 2> /dev/null && continue
|
||||
#
|
||||
# discharging=$(grep -qi "discharging" "$batpath/status" && echo "true" || echo "false")
|
||||
# bat_capacity="$batpath/capacity"
|
||||
# if [ -r "$bat_capacity" ]; then
|
||||
# charge=$(awk -v charge="$charge" -v capacity="$(cat "$bat_capacity")" 'BEGIN { print charge + (capacity > 100 ? 100 : capacity) / 100 }')
|
||||
# battery_charge=$(awk -v charge="$battery_charge" -v capacity="$(cat "$bat_capacity")" 'BEGIN { print charge + (capacity > 100 ? 100 : capacity) / 100 }')
|
||||
# else
|
||||
# bat_energy_full="$batpath/energy_full"
|
||||
# bat_energy_now="$batpath/energy_now"
|
||||
# if [ -r "$bat_energy_full" ] && [ -r "$bat_energy_now" ]; then
|
||||
# charge=$(awk -v charge="$charge" -v energy_now="$(cat "$bat_energy_now")" -v energy_full="$(cat "$bat_energy_full")" 'BEGIN { print charge + energy_now / energy_full }')
|
||||
# battery_charge=$(awk -v charge="$battery_charge" -v energy_now="$(cat "$bat_energy_now")" -v energy_full="$(cat "$bat_energy_full")" 'BEGIN { print charge + energy_now / energy_full }')
|
||||
# fi
|
||||
# fi
|
||||
# count=$((count + 1))
|
||||
# battery_count=$((battery_count + 1))
|
||||
# done << EOF
|
||||
# $(find /sys/class/power_supply -maxdepth 1 -iname '*bat*')
|
||||
# EOF
|
||||
|
@ -339,9 +474,8 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration'
|
|||
# *CYGWIN*|*MSYS*|*MINGW*)
|
||||
# while IFS= read -r line; do
|
||||
# [ -z "$line" ] && continue
|
||||
# discharging=$(printf '%s' "$line" | awk '{ s = ($1 == 1) ? "true" : "false"; print s }')
|
||||
# charge=$(printf '%s' "$line" | awk -v charge="$charge" '{ print charge + $2 / 100 }')
|
||||
# count=$((count + 1))
|
||||
# battery_charge=$(printf '%s' "$line" | awk -v charge="$battery_charge" '{ print charge + $2 / 100 }')
|
||||
# battery_count=$((battery_count + 1))
|
||||
# done << EOF
|
||||
# $(wmic path Win32_Battery get BatteryStatus, EstimatedChargeRemaining 2> /dev/null | tr -d '\r' | tail -n +2 || true)
|
||||
# EOF
|
||||
|
@ -349,36 +483,81 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration'
|
|||
# *OpenBSD*)
|
||||
# for batid in 0 1 2; do
|
||||
# sysctl -n "hw.sensors.acpibat$batid.raw0" 2>&1 | grep -q 'not found' && continue
|
||||
# discharging=$(sysctl -n "hw.sensors.acpibat$batid.raw0" | grep -q 1 && echo "true" || echo "false")
|
||||
# if sysctl -n "hw.sensors.acpibat$batid" | grep -q amphour; then
|
||||
# charge=$(awk -v charge="$charge" -v remaining="$(sysctl -n hw.sensors.acpibat$batid.amphour3 | cut -d' ' -f1)" -v full="$(sysctl -n hw.sensors.acpibat$batid.amphour0 | cut -d' ' -f1)" 'BEGIN { print charge + remaining / full }')
|
||||
# battery_charge=$(awk -v charge="$battery_charge" -v remaining="$(sysctl -n hw.sensors.acpibat$batid.amphour3 | cut -d' ' -f1)" -v full="$(sysctl -n hw.sensors.acpibat$batid.amphour0 | cut -d' ' -f1)" 'BEGIN { print charge + remaining / full }')
|
||||
# else
|
||||
# charge=$(awk -v charge="$charge" -v remaining="$(sysctl -n hw.sensors.acpibat$batid.watthour3 | cut -d' ' -f1)" -v full="$(sysctl -n hw.sensors.acpibat$batid.watthour0 | cut -d' ' -f1)" 'BEGIN { print charge + remaining / full }')
|
||||
# battery_charge=$(awk -v charge="$battery_charge" -v remaining="$(sysctl -n hw.sensors.acpibat$batid.watthour3 | cut -d' ' -f1)" -v full="$(sysctl -n hw.sensors.acpibat$batid.watthour0 | cut -d' ' -f1)" 'BEGIN { print charge + remaining / full }')
|
||||
# fi
|
||||
# count=$((count + 1))
|
||||
# battery_count=$((battery_count + 1))
|
||||
# done
|
||||
# ;;
|
||||
# *FreeBSD*)
|
||||
# discharging=$(sysctl -n 'hw.acpi.battery.state' | grep -q 1 && echo "true" || echo "false")
|
||||
# charge=$(awk -v charge="$(sysctl -n 'hw.acpi.battery.life')" 'BEGIN { print charge / 100 }')
|
||||
# count=1
|
||||
# battery_charge=$(awk -v charge="$(sysctl -n 'hw.acpi.battery.life')" 'BEGIN { print charge / 100 }')
|
||||
# battery_count=1
|
||||
# ;;
|
||||
# esac
|
||||
# if [ "$count" -ne 0 ]; then
|
||||
# charge=$(awk -v charge="$charge" -v count="$count" 'BEGIN { print charge / count }')
|
||||
# if [ "$battery_count" -ne 0 ]; then
|
||||
# battery_charge=$(awk -v charge="$battery_charge" -v count="$battery_count" 'BEGIN { print charge / count }')
|
||||
# fi
|
||||
#
|
||||
# if [ "$battery_charge" = 0 ]; then
|
||||
# tmux set -ug '@battery_percentage' \;\
|
||||
# set -ug '@battery_charge'
|
||||
# else
|
||||
# battery_percentage="$(awk "BEGIN { printf \"%.0f%%\", ($battery_charge) * 100 }")"
|
||||
#
|
||||
# tmux set -g '@battery_percentage' "$battery_percentage" \;\
|
||||
# set -g '@battery_charge' "$battery_charge"
|
||||
# fi
|
||||
# }
|
||||
#
|
||||
# _battery_status() {
|
||||
# _battery_info
|
||||
# if [ "$charge" = 0 ]; then
|
||||
# battery_status_charging=$1
|
||||
# battery_status_discharging=$2
|
||||
#
|
||||
# case "$_uname_s" in
|
||||
# *Darwin*)
|
||||
# while IFS= read -r line; do
|
||||
# [ -z "$line" ] && continue
|
||||
# battery_discharging=$(printf '%s' "$line" | grep -qi "discharging" && echo "true" || echo "false")
|
||||
# done << EOF
|
||||
# $(pmset -g batt | grep 'InternalBattery')
|
||||
# EOF
|
||||
# ;;
|
||||
# *Linux*)
|
||||
# while IFS= read -r batpath; do
|
||||
# [ -z "$batpath" ] && continue
|
||||
# grep -i -q device "$batpath/scope" 2> /dev/null && continue
|
||||
#
|
||||
# battery_discharging=$(grep -qi "discharging" "$batpath/status" && echo "true" || echo "false")
|
||||
# done << EOF
|
||||
# $(find /sys/class/power_supply -maxdepth 1 -iname '*bat*')
|
||||
# EOF
|
||||
# ;;
|
||||
# *CYGWIN*|*MSYS*|*MINGW*)
|
||||
# while IFS= read -r line; do
|
||||
# [ -z "$line" ] && continue
|
||||
# battery_discharging=$(printf '%s' "$line" | awk '{ s = ($1 == 1) ? "true" : "false"; print s }')
|
||||
# done << EOF
|
||||
# $(wmic path Win32_Battery get BatteryStatus, EstimatedChargeRemaining 2> /dev/null | tr -d '\r' | tail -n +2 || true)
|
||||
# EOF
|
||||
# ;;
|
||||
# *OpenBSD*)
|
||||
# for batid in 0 1 2; do
|
||||
# battery_discharging=$(sysctl -n "hw.sensors.acpibat$batid.raw0" | grep -q 1 && echo "true" || echo "false")
|
||||
# done
|
||||
# ;;
|
||||
# *FreeBSD*)
|
||||
# battery_discharging=$(sysctl -n 'hw.acpi.battery.state' | grep -q 1 && echo "true" || echo "false")
|
||||
# ;;
|
||||
# esac
|
||||
#
|
||||
# if [ -z "$battery_discharging" ]; then
|
||||
# tmux set -ug '@battery_status'
|
||||
# return
|
||||
# fi
|
||||
#
|
||||
# battery_status_charging=$1
|
||||
# battery_status_discharging=$2
|
||||
# if [ "$discharging" = "true" ]; then
|
||||
# if [ "$battery_discharging" = "true" ]; then
|
||||
# battery_status="$battery_status_discharging"
|
||||
# else
|
||||
# battery_status="$battery_status_charging"
|
||||
|
@ -387,138 +566,6 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration'
|
|||
# tmux set -g '@battery_status' "$battery_status"
|
||||
# }
|
||||
#
|
||||
# _battery_bar() {
|
||||
# _battery_info
|
||||
# if [ "$charge" = 0 ]; then
|
||||
# tmux set -ug '@battery_bar' \;\
|
||||
# set -ug '@battery_hbar' \;\
|
||||
# set -ug '@battery_vbar' \;\
|
||||
# set -ug '@battery_percentage'
|
||||
# return
|
||||
# fi
|
||||
#
|
||||
# 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
|
||||
#
|
||||
# if [ "$battery_bar_length" = "auto" ]; then
|
||||
# columns=$(tmux -q display -p '#{client_width}' 2> /dev/null || echo 80)
|
||||
# if [ "$columns" -ge 80 ]; then
|
||||
# battery_bar_length=10
|
||||
# else
|
||||
# battery_bar_length=5
|
||||
# fi
|
||||
# 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; }
|
||||
# palette_style=$1
|
||||
# battery_bg=${2:-none}
|
||||
# [ "$palette_style" = "gradient" ] && \
|
||||
# palette="196 202 208 214 220 226 190 154 118 82 46"
|
||||
# [ "$palette_style" = "heat" ] && \
|
||||
# palette="243 245 247 144 143 142 184 214 208 202 196"
|
||||
#
|
||||
# palette=$(echo "$palette" | awk -v n="$battery_bar_length" '{ for (i = 0; i < n; ++i) printf $(1 + (i * NF / n))" " }')
|
||||
# eval set -- "$palette"
|
||||
#
|
||||
# full=$(awk "BEGIN { printf \"%.0f\", ($charge) * $battery_bar_length }")
|
||||
# battery_bar="#[bg=$battery_bg]"
|
||||
# # shellcheck disable=SC2046
|
||||
# [ "$full" -gt 0 ] && \
|
||||
# battery_bar="$battery_bar$(printf "#[fg=colour%s]$battery_bar_symbol_full" $(echo "$palette" | cut -d' ' -f1-"$full"))"
|
||||
# # shellcheck disable=SC2046
|
||||
# empty=$((battery_bar_length - full))
|
||||
# # shellcheck disable=SC2046
|
||||
# [ "$empty" -gt 0 ] && \
|
||||
# battery_bar="$battery_bar$(printf "#[fg=colour%s]$battery_bar_symbol_empty" $(echo "$palette" | cut -d' ' -f$((full + 1))-$((full + empty))))"
|
||||
# eval battery_bar="$battery_bar#[fg=colour\${$((full == 0 ? 1 : full))}]"
|
||||
# elif echo "$battery_bar_palette" | grep -q -E '^(([#a-z0-9]{7,9}|none),?){3}$'; then
|
||||
# # shellcheck disable=SC2086
|
||||
# { set -f; IFS=,; set -- $battery_bar_palette; unset IFS; set +f; }
|
||||
# battery_full_fg=$1
|
||||
# battery_empty_fg=$2
|
||||
# battery_bg=$3
|
||||
#
|
||||
# full=$(awk "BEGIN { printf \"%.0f\", ($charge) * $battery_bar_length }")
|
||||
# [ "$battery_bg" != "none" ] && \
|
||||
# battery_bar="#[bg=$battery_bg]"
|
||||
# #shellcheck disable=SC2046
|
||||
# [ "$full" -gt 0 ] && \
|
||||
# battery_bar="$battery_bar#[fg=$battery_full_fg]$(printf "%0.s$battery_bar_symbol_full" $(seq 1 "$full"))"
|
||||
# empty=$((battery_bar_length - full))
|
||||
# #shellcheck disable=SC2046
|
||||
# [ "$empty" -gt 0 ] && \
|
||||
# battery_bar="$battery_bar#[fg=$battery_empty_fg]$(printf "%0.s$battery_bar_symbol_empty" $(seq 1 "$empty"))" && \
|
||||
# battery_bar="$battery_bar#[fg=$battery_empty_fg]"
|
||||
# fi
|
||||
#
|
||||
# if echo "$battery_hbar_palette" | grep -q -E '^heat|gradient(,[#a-z0-9]{7,9})?$'; then
|
||||
# # shellcheck disable=SC2086
|
||||
# { set -f; IFS=,; set -- $battery_hbar_palette; unset IFS; set +f; }
|
||||
# palette_style=$1
|
||||
# [ "$palette_style" = "gradient" ] && \
|
||||
# palette="196 202 208 214 220 226 190 154 118 82 46"
|
||||
# [ "$palette_style" = "heat" ] && \
|
||||
# palette="233 234 235 237 239 241 243 245 247 144 143 142 184 214 208 202 196"
|
||||
#
|
||||
# palette=$(echo "$palette" | awk -v n="$battery_bar_length" '{ for (i = 0; i < n; ++i) printf $(1 + (i * NF / n))" " }')
|
||||
# eval set -- "$palette"
|
||||
#
|
||||
# full=$(awk "BEGIN { printf \"%.0f\", ($charge) * $battery_bar_length }")
|
||||
# eval battery_hbar_fg="colour\${$((full == 0 ? 1 : full))}"
|
||||
# elif echo "$battery_hbar_palette" | grep -q -E '^([#a-z0-9]{7,9},?){3}$'; then
|
||||
# # shellcheck disable=SC2086
|
||||
# { set -f; IFS=,; set -- $battery_hbar_palette; unset IFS; set +f; }
|
||||
#
|
||||
# # shellcheck disable=SC2046
|
||||
# eval $(awk "BEGIN { printf \"battery_hbar_fg=$%d\", (($charge) - 0.001) * $# + 1 }")
|
||||
# fi
|
||||
#
|
||||
# eval set -- "▏ ▎ ▍ ▌ ▋ ▊ ▉ █"
|
||||
# # shellcheck disable=SC2046
|
||||
# eval $(awk "BEGIN { printf \"battery_hbar_symbol=$%d\", ($charge) * ($# - 1) + 1 }")
|
||||
# battery_hbar="#[fg=${battery_hbar_fg?}]${battery_hbar_symbol?}"
|
||||
#
|
||||
# if echo "$battery_vbar_palette" | grep -q -E '^heat|gradient(,[#a-z0-9]{7,9})?$'; then
|
||||
# # shellcheck disable=SC2086
|
||||
# { set -f; IFS=,; set -- $battery_vbar_palette; unset IFS; set +f; }
|
||||
# palette_style=$1
|
||||
# [ "$palette_style" = "gradient" ] && \
|
||||
# palette="196 202 208 214 220 226 190 154 118 82 46"
|
||||
# [ "$palette_style" = "heat" ] && \
|
||||
# palette="233 234 235 237 239 241 243 245 247 144 143 142 184 214 208 202 196"
|
||||
#
|
||||
# palette=$(echo "$palette" | awk -v n="$battery_bar_length" '{ for (i = 0; i < n; ++i) printf $(1 + (i * NF / n))" " }')
|
||||
# eval set -- "$palette"
|
||||
#
|
||||
# full=$(awk "BEGIN { printf \"%.0f\", ($charge) * $battery_bar_length }")
|
||||
# eval battery_vbar_fg="colour\${$((full == 0 ? 1 : full))}"
|
||||
# elif echo "$battery_vbar_palette" | grep -q -E '^([#a-z0-9]{7,9},?){3}$'; then
|
||||
# # shellcheck disable=SC2086
|
||||
# { set -f; IFS=,; set -- $battery_vbar_palette; unset IFS; set +f; }
|
||||
#
|
||||
# # shellcheck disable=SC2046
|
||||
# eval $(awk "BEGIN { printf \"battery_vbar_fg=$%d\", (($charge) - 0.001) * $# + 1 }")
|
||||
# fi
|
||||
#
|
||||
# eval set -- "▁ ▂ ▃ ▄ ▅ ▆ ▇ █"
|
||||
# # shellcheck disable=SC2046
|
||||
# eval $(awk "BEGIN { printf \"battery_vbar_symbol=$%d\", ($charge) * ($# - 1) + 1 }")
|
||||
# battery_vbar="#[fg=${battery_vbar_fg?}]${battery_vbar_symbol?}"
|
||||
#
|
||||
# battery_percentage="$(awk "BEGIN { printf \"%.0f%%\", ($charge) * 100 }")"
|
||||
#
|
||||
# tmux set -g '@battery_bar' "$battery_bar" \;\
|
||||
# set -g '@battery_hbar' "$battery_hbar" \;\
|
||||
# set -g '@battery_vbar' "$battery_vbar" \;\
|
||||
# set -g '@battery_percentage' "$battery_percentage"
|
||||
# }
|
||||
#
|
||||
# _pane_info() {
|
||||
# pane_pid="$1"
|
||||
# pane_tty="${2##/dev/}"
|
||||
|
@ -1345,33 +1392,39 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration'
|
|||
# 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
|
||||
#
|
||||
# _pkillf "cut -c3- '$TMUX_CONF' \| sh -s _battery_bar"
|
||||
# _pkillf "cut -c3- '$TMUX_CONF' \| sh -s _battery"
|
||||
# _battery_info
|
||||
# if [ "$charge" != 0 ]; then
|
||||
# if [ "$battery_charge" != 0 ]; then
|
||||
# case "$status_left $status_right" in
|
||||
# *'#{battery_'*|*'#{?battery_'*)
|
||||
# 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_bar%#\{?@battery_percentage%g' \
|
||||
# -e 's%#\{\?battery_hbar%#\{?@battery_percentage%g' \
|
||||
# -e 's%#\{\?battery_vbar%#\{?@battery_percentage%g' \
|
||||
# -e "s%#{battery_bar}%#(nice cut -c3- '$TMUX_CONF' | sh -s _bar '$tmux_conf_battery_bar_palette' '$tmux_conf_battery_bar_symbol_empty' '$tmux_conf_battery_bar_symbol_full' '$tmux_conf_battery_bar_length' '#{@battery_charge}' '#{client_width}')%g" \
|
||||
# -e "s%#{battery_hbar}%#(nice cut -c3- '$TMUX_CONF' | sh -s _hbar '$tmux_conf_battery_hbar_palette' '#{@battery_charge}'')%g" \
|
||||
# -e "s%#{battery_vbar}%#(nice cut -c3- '$TMUX_CONF' | sh -s _vbar '$tmux_conf_battery_hbar_palette' '#{@battery_charge}'')%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')
|
||||
# -e 's%#\{\?battery_bar%#\{?@battery_percentage%g' \
|
||||
# -e 's%#\{\?battery_hbar%#\{?@battery_percentage%g' \
|
||||
# -e 's%#\{\?battery_vbar%#\{?@battery_percentage%g' \
|
||||
# -e "s%#{battery_bar}%#(nice cut -c3- '$TMUX_CONF' | sh -s _bar '$tmux_conf_battery_bar_palette' '$tmux_conf_battery_bar_symbol_empty' '$tmux_conf_battery_bar_symbol_full' '$tmux_conf_battery_bar_length' '#{@battery_charge}' '#{client_width}')%g" \
|
||||
# -e "s%#{battery_hbar}%#(nice cut -c3- '$TMUX_CONF' | sh -s _hbar '$tmux_conf_battery_hbar_palette' '#{@battery_charge}'')%g" \
|
||||
# -e "s%#{battery_vbar}%#(nice cut -c3- '$TMUX_CONF' | sh -s _vbar '$tmux_conf_battery_hbar_palette' '#{@battery_charge}'')%g" \
|
||||
# -e 's%#\{(\?)?battery_status%#\{\1@battery_status%g' \
|
||||
# -e 's%#\{(\?)?battery_percentage%#\{\1@battery_percentage%g')
|
||||
# status_right="#(echo; nice cut -c3- '$TMUX_CONF' | sh -s _battery_status '$tmux_conf_battery_status_charging' '$tmux_conf_battery_status_discharging')$status_right"
|
||||
# interval=60
|
||||
# if [ "$_tmux_version" -ge 320 ]; then
|
||||
# tmux run -b "trap '[ -n \"\$sleep_pid\" ] && kill -9 \"\$sleep_pid\"; exit 0' TERM; while [ x\"\$('$TMUX_PROGRAM' -S '#{socket_path}' display -p '#{l:#{pid}}')\" = x\"#{pid}\" ]; 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 & sleep_pid=\$!; wait \"\$sleep_pid\"; sleep_pid=; done"
|
||||
# tmux run -b "trap '[ -n \"\$sleep_pid\" ] && kill -9 \"\$sleep_pid\"; exit 0' TERM; while [ x\"\$('$TMUX_PROGRAM' -S '#{socket_path}' display -p '#{l:#{pid}}')\" = x\"#{pid}\" ]; do nice cut -c3- '$TMUX_CONF' | sh -s _battery_info; sleep $interval & sleep_pid=\$!; wait \"\$sleep_pid\"; sleep_pid=; done"
|
||||
# elif [ "$_tmux_version" -ge 280 ]; then
|
||||
# status_right="#(echo; while [ x\"\$('$TMUX_PROGRAM' -S '#{socket_path}' display -p '#{l:#{pid}}')\" = x\"#{pid}\" ]; 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"
|
||||
# status_right="#(echo; while [ x\"\$('$TMUX_PROGRAM' -S '#{socket_path}' display -p '#{l:#{pid}}')\" = x\"#{pid}\" ]; do nice cut -c3- '$TMUX_CONF' | sh -s _battery_info; sleep $interval; done)$status_right"
|
||||
# elif [ "$_tmux_version" -gt 240 ]; then
|
||||
# status_right="#(echo; 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"
|
||||
# status_right="#(echo; while :; do nice cut -c3- '$TMUX_CONF' | sh -s _battery_info; sleep $interval; done)$status_right"
|
||||
# else
|
||||
# status_right="#(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')$status_right"
|
||||
# status_right="#(nice cut -c3- '$TMUX_CONF' | sh -s _battery_info)$status_right"
|
||||
# fi
|
||||
# ;;
|
||||
# esac
|
||||
|
|
|
@ -271,9 +271,10 @@ your own preferences.
|
|||
This configuration supports the following builtin variables:
|
||||
|
||||
- `#{battery_bar}`: horizontal battery charge bar
|
||||
- `#{battery_hbar}`: 1 character wide, horizontal battery charge bar
|
||||
- `#{battery_vbar}`: 1 character wide, vertical battery charge bar
|
||||
- `#{battery_percentage}`: battery percentage
|
||||
- `#{battery_status}`: is battery charging or discharging?
|
||||
- `#{battery_vbar}`: vertical battery charge bar
|
||||
- `#{circled_session_name}`: circled session number, up to 20
|
||||
- `#{hostname}`: SSH/Mosh aware hostname information
|
||||
- `#{hostname_ssh}`: SSH/Mosh aware hostname information, blank when not
|
||||
|
|
Loading…
Reference in a new issue