跳到主要内容
    ↑↓ 选择↵ 打开esc 关闭
    davissekai

    Notify Crossx

    opencode-notify-crossx·v0.1.0·通知与集成

    Cross-platform desktop notifications for opencode — pings when run finishes or input is needed. Focus-aware, WSL + macOS + Linux. No sound by default, visual toast only.

    GitHub 星标

    0

    月装机量

    53

    近 7 天 6

    综合评分

    28.8

    生态多维模型

    最近提交

    1 个月前

    2026-08-26

    快速安装与配置

    opencode.json

    写入当前项目的 opencode.json,只对这个仓库生效。

    opencode.json

    {
      "$schema": "https://opencode.ai/config.json",
      "plugin": ["opencode-notify-crossx@0.1.0"]
    }

    OpenCode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。

    Cross-platform desktop notifications for opencode — get pinged when your run finishes or when input is needed.

    Focus-aware: only pings when opencode is not the frontmost window, so you are not spammed while watching.

    Platform Visual Sound (off by default) Focus check
    WSL (Windows) PowerShell Windows.UI.Notifications toast SystemSounds GetForegroundWindow
    macOS osascript display notification afplay System Events frontmost
    Linux notify-send via libnotify paplay xdotool

    No sound by default — visual toast only. Set sound: true in code to re-enable.

    Install

    npm i -g opencode-notify-crossx
    # or for local install
    npm i opencode-notify-crossx
    

    Add to your opencode config:

    ~/.config/opencode/opencode.json:

    {
      "$schema": "https://opencode.ai/config.json",
      "plugin": ["opencode-notify-crossx"]
    }
    

    Or project-level .opencode/opencode.json:

    {
      "plugin": ["opencode-notify-crossx"]
    }
    

    Restart opencode.

    What triggers a ping

    • session.idle → Run finished
    • session.error → Run failed
    • permission.updated / permission.ask → Input needed

    Debounced per session/permission to avoid spam.

    Focus-aware

    Only notifies when the terminal is not focused. If opencode is the frontmost window (Windows Terminal, VS Code, etc.), the ping is suppressed and logged as suppressed (focused).

    To notify even when focused, edit index.js:

    const CONFIG = {
      onlyWhenUnfocused: false, // always ping
      sound: false,
    }
    

    Sound

    Off by default per user request. To enable:

    const CONFIG = {
      sound: true,
    }
    

    Local development (single-file plugin)

    The same code also works as a single-file local plugin at ~/.config/opencode/plugins/notify.js — no npm needed. See index.js source.

    How it works

    • isWsl() checks /proc/version for microsoft/wsl
    • isTerminalFocused() checks foreground window title via PowerShell on WSL/Windows, AppleScript on macOS, xdotool on Linux
    • sendDesktop() tries osascript → PowerShell toast → notify-send in order
    • notify() respects CONFIG.onlyWhenUnfocused and CONFIG.sound

    License

    MIT

    Author

    Davis Dey — first open source contribution, built live with opencode

    同类生态推荐