Files
notify/scripts/notify.sh
T
chuan 5ce2c8a982 feat: Claude Code 原生 Windows 通知(C# / .NET 10 + Avalonia 12)
为 Claude Code 提供原生 Windows toast 通知:点击跳回原窗口、切回 Windows
Terminal 标签、跨虚拟桌面、调用方图标、非阻塞投递;NativeAOT 单文件分发。
2026-06-22 18:05:15 +08:00

41 lines
1.4 KiB
Bash

#!/bin/sh
# ============================================================
# 下载地址(首次运行从这里拉取 notify.exe)—— 按需修改
DOWNLOAD_URL="https://git.pchuan.top/cc-tools/notify/releases/download/v1.0.0/notify.exe"
# ============================================================
DIR="$(cd "$(dirname "$0")" && pwd)"
BIN="$DIR/../bin"
EXE="$BIN/notify.exe"
LOCK="$BIN/notify.download.lock"
if [ ! -f "$EXE" ]; then
mkdir -p "$BIN" 2>/dev/null
# mkdir 是原子操作,用作锁:成功=本进程负责下载,失败=已有进程在下
if mkdir "$LOCK" 2>/dev/null; then
# 双重检查,避免刚好别人下完
if [ ! -f "$EXE" ]; then
TMP="$BIN/notify.exe.$$.tmp"
if curl -fsSL "$DOWNLOAD_URL" -o "$TMP"; then
mv -f "$TMP" "$EXE" # 原子改名,避免半截 exe
chmod +x "$EXE" 2>/dev/null
else
rm -f "$TMP"
fi
fi
rmdir "$LOCK" 2>/dev/null
else
# 没抢到锁:等 exe 出现(最多约 60 秒)
i=0
while [ ! -f "$EXE" ] && [ "$i" -lt 120 ]; do
sleep 0.5
i=$((i + 1))
done
# 超时仍没下好:可能上次下载被杀留下陈旧锁,清掉让下次重下
[ ! -f "$EXE" ] && rmdir "$LOCK" 2>/dev/null
fi
fi
# 转发全部参数与 stdin 给真正的 exe
[ -f "$EXE" ] && exec "$EXE" "$@"