mohak34/opencode-notifier: OpenCode plugin for desktop notifications and sounds on permission, completion, and error

5 phút đọc

mohak34/opencode-notifier: OpenCode plugin for desktop notifications and sounds on permission, completion, and error – Repository mohak34/opencode-notifier. Mô tả: OpenCode plugin for desktop notifications and sounds on permission, completion, and error events.. 857 stars, 88 forks, ngôn ngữ chính TypeScript, cập nhật 2026-10-17.

1. Repository làm gì?

OpenCode plugin that plays sounds and sends system notifications when permission is needed, generation completes, errors occur, or the question tool is invoked. Works on macOS, Linux, and Windows.

For OpenCode 1, add the package to opencode.json:

Restart OpenCode. The package contains both implementations; you do not select a version manually. V2 loads the package's terminal component automatically in the interactive CLI.

Sounds, desktop popups, terminal bells, Ghostty notifications, and focus detection run in the terminal client. Custom commands run once per event on the server, including when no terminal is open. This uses the existing command configuration; no external notification service is bundled.

With a remote server, put sound and popup settings on your local computer and custom-command settings on the server. Event-command script paths refer to the server's filesystem. Click-command paths refer to the computer displaying the notification. Focus suppression applies to local alerts, not server commands. Each attached terminal receives alerts for its project. On one computer, clients with the session's family open in a tab or current route take priority over unrelated clients in the same project. If several eligible clients have it open, only the first to claim the event alerts. If none have it open, an eligible client still alerts after a brief fallback grace; terminals on other computers each alert.

Clients publish their open-session IDs in private temporary files, refreshed once per second and removed on disposal. Dead processes and presence older than five seconds are ignored. If the registry or client-local UI APIs are unavailable, alerts fail open through the existing event claim.

2. Dữ liệu và cấu trúc đáng chú ý

opencode run and Desktop/Web clients do not load this terminal component, so they receive no plugin sound, popup, or bell. Server commands still run. V1 delivery and its enableOnDesktop behavior are unchanged.

V2 already includes a notification plugin. To avoid duplicate built-in alerts, add "-opencode.notifications" to the existing plugins list in ~/.config/opencode/cli.json:

Keep any other entries in that list, with "-opencode.notifications" after matching enable entries such as "*" or "opencode.*". A later enable entry can turn the built-in alerts back on. plan_exit remains a V1 event; V2 has no equivalent plan-ready signal, so that setting is inactive there. client_connected is best-effort: terminal startup for local alerts, server plugin startup for custom commands.

There's also subagent_complete for when subagents finish, and user_cancelled for when you press ESC to abort — both are silent by default so you don't get spammed.

macOS: Nothing to do, works out of the box. Shows the Script Editor icon.

Linux: Should work if you already have a notification system setup. If not install libnotify:

For sounds, you need one of: paplay, aplay, mpv, or ffplay

3. Khả năng ứng dụng và giới hạn

Windows: Works out of the box. But heads up:

WSL: Set customIconPath to a file on the Windows filesystem to avoid icon-path translation issues. You can copy an icon from this repository's logos folder. The path is passed to snoretoast-*.exe.

In opencode-notifier.json config:

Create ~/.config/opencode/opencode-notifier.json with this example configuration. Omitted settings use their defaults:

user_cancelled fires when you press ESC to abort a session. It's silent by default so intentional cancellations don't trigger error alerts. Set sound or notification to true if you want confirmation when cancelling.

session_started fires when a new top-level session is created. user_message fires when a user message is submitted in a top-level session. client_connected is best-effort. On V1 it fires shortly after plugin initialization. On V2, terminal initialization triggers local alerts and server plugin initialization triggers the custom command; it does not track every client reconnection.

The command property controls whether the custom command (see Custom commands) runs for that event. Defaults to true for all events. Set it to false to suppress the command for specific events without disabling it globally.

bell is terminal-driven and may be audible, visual, both, or ignored depending on your terminal setup. Quick check: printf '\a'.

Boolean shorthand sets sound, notification, and command together. It preserves the inherited bell setting:

Số liệu repository có thể thay đổi; nên mở liên kết nguồn để kiểm tra README, giấy phép và trạng thái phát hành.

Nguồn tham khảo: Xem bài gốc

📅 Âm: 4/10 · Canh Dần

📅 Lịch Âm Dương NsN

×
Hôm Nay · Thứ Năm
Âm Lịch: 4 Tháng 10
Năm Bính Ngọ
📌 Can Chi: Canh Dần
✨ Hoàng Đạo: Tý (23-1), Sửu (1-3), Thìn (7-9), Tỵ (9-11), Mùi (13-15), Tuất (19-21)
Vĩnh Phúc (Liên Bảo - Vĩnh Yên)
31°C
Nắng Đẹp
💧 83% | 💨 18 km/h
Hôm nay 32°
02/11 28°
03/11 30°
04/11 31°
05/11 31°