diff --git a/.config/opencode/plugin/notify-send.ts b/.config/opencode/plugin/notify-send.ts new file mode 100644 index 0000000..2099ad9 --- /dev/null +++ b/.config/opencode/plugin/notify-send.ts @@ -0,0 +1,38 @@ +import { Plugin } from "@opencode-ai/plugin"; + +export const NotifySendPlugin: Plugin = async ({ $ }) => { + const mainSessions = new Set(); + const notify = async (summary: string, body: string) => { + try { + await $`notify-send -i ~/.config/opencode/plugin/opencode-logo-dark.svg ${summary} ${body}`; + } catch { } + }; + + return { + event: async ({ event }) => { + switch (event.type) { + case "session.created": + const session = event.properties.info; + if (!session.parentID) { + mainSessions.add(session.id); + } + break; + case "session.deleted": + mainSessions.delete(event.properties.info.id); + break; + case "session.status": + const { sessionID, status } = event.properties; + if (status.type === "idle" && mainSessions.has(sessionID)) { + await notify("OpenCode", "Session status updated"); + } + break; + case "question.asked": + await notify("OpenCode", "Question asked"); + break; + case "permission.asked": + await notify("OpenCode", "Permission requested"); + break; + } + }, + }; +}; diff --git a/.config/opencode/plugin/opencode-logo-dark.svg b/.config/opencode/plugin/opencode-logo-dark.svg new file mode 100644 index 0000000..b79c733 --- /dev/null +++ b/.config/opencode/plugin/opencode-logo-dark.svg @@ -0,0 +1 @@ + \ No newline at end of file