diff --git a/home-configs/claude/statusline-command.sh b/home-configs/claude/statusline-command.sh index a4c3502..7ee2422 100644 --- a/home-configs/claude/statusline-command.sh +++ b/home-configs/claude/statusline-command.sh @@ -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