feat(heartbeat): simplify to color-only lerp fade
Heartbeat now emits only a tmux fg color that interpolates teal to gray based on activity score. Status-right supplies the time display directly. Removes bar/pill/time rendering. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -68,7 +68,7 @@ set -g status-position bottom
|
|||||||
set -g status-interval 1
|
set -g status-interval 1
|
||||||
set -g status-style "fg=#7290B8,bg=default"
|
set -g status-style "fg=#7290B8,bg=default"
|
||||||
set -g status-left "#{?client_prefix,#[fg=colour208]● ,#[fg=#3C3C3C]● }"
|
set -g status-left "#{?client_prefix,#[fg=colour208]● ,#[fg=#3C3C3C]● }"
|
||||||
set -g status-right "#{?@condensed,,#{?#{e|>=|:#{client_width},120},#(~/.tmux/network.sh) #[fg=#3C3C3C] #(~/.tmux/battery.sh) #[fg=#3C3C3C] ,}}#{?@condensed,,#{?#{e|>=|:#{client_width},80},#[fg=#808080]%a %d %b ,}}#{?@condensed,#[fg=#3C3C3C]‹,}#[fg=#2CB494]#[bg=#1A1A1A] %H:%M #[default]#(~/.tmux/heartbeat.sh)"
|
set -g status-right "#{?#{e|>=|:#{client_width},120},#(~/.tmux/network.sh) #[fg=#3C3C3C] #(~/.tmux/battery.sh) #[fg=#3C3C3C] ,}#{?#{e|>=|:#{client_width},80},#[fg=#808080]%a %d %b ,}#(~/.tmux/heartbeat.sh)#[bg=#1A1A1A] %H:%M #[default]"
|
||||||
set -g status-right-length 80
|
set -g status-right-length 80
|
||||||
set -g window-status-format "#{?window_last_flag, #[fg=#1A7A64]#I#[fg=default] #W , #I #W }"
|
set -g window-status-format "#{?window_last_flag, #[fg=#1A7A64]#I#[fg=default] #W , #I #W }"
|
||||||
set -g window-status-current-format " #[fg=#085040]#I#[fg=#0A0A0A] #W "
|
set -g window-status-current-format " #[fg=#085040]#I#[fg=#0A0A0A] #W "
|
||||||
|
|||||||
@@ -9,11 +9,7 @@
|
|||||||
# Score capped at 100, floored at 0.
|
# Score capped at 100, floored at 0.
|
||||||
#
|
#
|
||||||
# Counter ticks while score > 0. Resets on tmux restart.
|
# Counter ticks while score > 0. Resets on tmux restart.
|
||||||
#
|
# Outputs a tmux fg color that fades from teal to gray with activity.
|
||||||
# Visual (pill with pressure bar):
|
|
||||||
# 23m ▆ — teal time + teal bar (active, score > 0)
|
|
||||||
# 5m — gray time, no bar (paused, score = 0)
|
|
||||||
# 10s ▃ — amber time + amber bar (returning from away)
|
|
||||||
|
|
||||||
SCORE_CAP=100
|
SCORE_CAP=100
|
||||||
|
|
||||||
@@ -44,18 +40,16 @@ if [[ -f "$state" ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Score: check activity signals
|
# Score: check activity signals
|
||||||
gaining=0
|
|
||||||
|
|
||||||
if [[ -n "$prev_client" && "$client_act" != "$prev_client" ]]; then
|
if [[ -n "$prev_client" && "$client_act" != "$prev_client" ]]; then
|
||||||
(( score += 5 )); gaining=1
|
(( score += 5 ))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "$prev_win" && "$win_act" != "$prev_win" ]]; then
|
if [[ -n "$prev_win" && "$win_act" != "$prev_win" ]]; then
|
||||||
(( score += 2 )); gaining=1
|
(( score += 2 ))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$in_mode" == "1" ]]; then
|
if [[ "$in_mode" == "1" ]]; then
|
||||||
(( score += 2 )); gaining=1
|
(( score += 2 ))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
(( score-- ))
|
(( score-- ))
|
||||||
@@ -73,42 +67,18 @@ fi
|
|||||||
printf 'prev_client=%s\nprev_win=%s\nscore=%s\nactive_total=%s\nsrv_pid=%s\nreturn_at=%s\nreturn_show=%s\n' \
|
printf 'prev_client=%s\nprev_win=%s\nscore=%s\nactive_total=%s\nsrv_pid=%s\nreturn_at=%s\nreturn_show=%s\n' \
|
||||||
"$client_act" "$win_act" "$score" "$active_total" "$tmux_pid" "$return_at" "$return_show" > "$state"
|
"$client_act" "$win_act" "$score" "$active_total" "$tmux_pid" "$return_at" "$return_show" > "$state"
|
||||||
|
|
||||||
# Format seconds to ≤3 chars
|
# Output: tmux color code that fades teal (#2CB494) → gray (#808080)
|
||||||
fmt() {
|
# Interpolate RGB channels based on score (0-100)
|
||||||
local s=$1
|
lerp() {
|
||||||
if (( s < 60 )); then printf "%ds" "$s"
|
local from=$1 to=$2 pct=$3
|
||||||
elif (( s < 3600 )); then printf "%dm" $(( s / 60 ))
|
echo $(( from + (to - from) * pct / 100 ))
|
||||||
elif (( s < 86400 )); then printf "%dh" $(( s / 3600 ))
|
|
||||||
else printf "%dd" $(( s / 86400 )); fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Pressure bar: block fill (8 levels)
|
|
||||||
bar() {
|
|
||||||
local s=$1
|
|
||||||
if (( s >= 88 )); then printf '█'
|
|
||||||
elif (( s >= 75 )); then printf '▇'
|
|
||||||
elif (( s >= 63 )); then printf '▆'
|
|
||||||
elif (( s >= 50 )); then printf '▅'
|
|
||||||
elif (( s >= 38 )); then printf '▄'
|
|
||||||
elif (( s >= 25 )); then printf '▃'
|
|
||||||
elif (( s >= 13 )); then printf '▂'
|
|
||||||
elif (( s >= 1 )); then printf '▁'
|
|
||||||
else printf ' '; fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Render: pill with margin (space + bg pill + space)
|
|
||||||
render() {
|
|
||||||
local bar_fg=$1 b=$2 time_fg=$3 txt=$4 len=${#4}
|
|
||||||
local rpad=""
|
|
||||||
(( len < 3 )) && printf -v rpad "%$(( 3 - len ))s" ""
|
|
||||||
printf " #[bg=#1A1A1A,fg=%s] %s%s #[fg=%s]%s#[default] " "$time_fg" "$txt" "$rpad" "$bar_fg" "$b"
|
|
||||||
}
|
|
||||||
|
|
||||||
b=$(bar $score)
|
|
||||||
if [[ -n "$return_at" ]]; then
|
if [[ -n "$return_at" ]]; then
|
||||||
render "colour208" "$b" "colour208" "$(fmt $return_show)"
|
printf '#[fg=colour208]'
|
||||||
elif (( score > 0 )); then
|
|
||||||
render "#2CB494" "$b" "#2CB494" "$(fmt $active_total)"
|
|
||||||
else
|
else
|
||||||
render "#808080" " " "#808080" "$(fmt $active_total)"
|
r=$(lerp 128 44 "$score")
|
||||||
|
g=$(lerp 128 180 "$score")
|
||||||
|
b=$(lerp 128 148 "$score")
|
||||||
|
printf '#[fg=#%02X%02X%02X]' "$r" "$g" "$b"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user