feat: раскрасить ctx по уровням и добавить звуковой сигнал при 60%
- зелёный <30%, жёлтый 30-50%, красный 50%+ - однократный звуковой сигнал (alarm-clock-elapsed.oga, 1s) при первом достижении 60% - сброс флага алерта когда ctx опускается ниже 50% Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -52,5 +52,29 @@ else
|
||||
fi
|
||||
fi
|
||||
|
||||
[ -n "$ctx_pct" ] && printf " \033[00;90mctx:$(printf '%.0f' "$ctx_pct")%%\033[00m"
|
||||
if [ -n "$ctx_pct" ]; then
|
||||
ctx_int=$(printf '%.0f' "$ctx_pct")
|
||||
if [ "$ctx_int" -lt 30 ]; then
|
||||
ctx_color="\033[00;32m"
|
||||
elif [ "$ctx_int" -lt 50 ]; then
|
||||
ctx_color="\033[00;33m"
|
||||
else
|
||||
ctx_color="\033[00;31m"
|
||||
fi
|
||||
printf " ${ctx_color}ctx:${ctx_int}%%\033[00m"
|
||||
|
||||
# Звуковой сигнал при первом достижении 60%
|
||||
alert_file="$HOME/.cache/ai-setup/ctx_alert_state"
|
||||
if [ "$ctx_int" -ge 60 ]; then
|
||||
if [ ! -f "$alert_file" ] || [ "$(cat "$alert_file")" != "alerted" ]; then
|
||||
mkdir -p "$HOME/.cache/ai-setup"
|
||||
echo "alerted" > "$alert_file"
|
||||
(timeout 1s paplay /usr/share/sounds/freedesktop/stereo/alarm-clock-elapsed.oga 2>/dev/null || \
|
||||
paplay /usr/share/sounds/freedesktop/stereo/dialog-warning.oga 2>/dev/null || \
|
||||
printf '\a') &
|
||||
fi
|
||||
elif [ "$ctx_int" -lt 50 ]; then
|
||||
rm -f "$alert_file" 2>/dev/null
|
||||
fi
|
||||
fi
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user