Files
notify/scripts/notify.cmd
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

46 lines
1.5 KiB
Batchfile

@echo off
rem ============================================================
rem Download URL (notify.exe is fetched from here on first run) -- edit as needed
set "DOWNLOAD_URL=https://git.pchuan.top/cc-tools/notify/releases/download/v1.0.0/notify.exe"
rem ============================================================
setlocal
set "BIN=%~dp0..\bin"
set "EXE=%BIN%\notify.exe"
set "LOCK=%BIN%\notify.download.lock"
rem only bootstrap on first run; the common path runs the exe directly (keeps piped stdin intact)
if not exist "%EXE%" call :bootstrap
if exist "%EXE%" "%EXE%" %*
endlocal
exit /b
:bootstrap
if not exist "%BIN%" mkdir "%BIN%" 2>nul
set "TMP=%BIN%\notify.exe.%RANDOM%.tmp"
rem mkdir is atomic; success = this process downloads, failure = someone else is downloading
mkdir "%LOCK%" 2>nul
if errorlevel 1 goto :waitdl
rem double-check in case it just finished
if exist "%EXE%" ( rmdir "%LOCK%" 2>nul & exit /b )
rem download to temp then atomic rename, so no half-written exe is ever seen
curl -fsSL "%DOWNLOAD_URL%" -o "%TMP%"
if errorlevel 1 ( del "%TMP%" 2>nul & rmdir "%LOCK%" 2>nul & exit /b )
move /y "%TMP%" "%EXE%" >nul
rmdir "%LOCK%" 2>nul
exit /b
:waitdl
rem did not get the lock; wait for the exe to appear (up to ~60s)
set /a _w=0
:waitloop
if exist "%EXE%" exit /b
if %_w% geq 120 (
rem timed out; a killed download may have left a stale lock, clear it for next time
rmdir "%LOCK%" 2>nul
exit /b
)
ping -n 2 127.0.0.1 >nul
set /a _w+=1
goto :waitloop