From ddbb0fdffeaccd841222c2f26b8c2783afc82833 Mon Sep 17 00:00:00 2001 From: Lukas de Boer Date: Thu, 26 Feb 2026 10:11:15 +0100 Subject: [PATCH] feat: add ghostty notification system support Add 'ghostty' as a notification system option that uses the OSC 777 escape sequence to send notifications natively through Ghostty terminal. This allows clicking notifications to bring the Ghostty window to the foreground, unlike osascript which opens Script Editor. --- src/config.ts | 11 ++++++++--- src/notify.ts | 12 +++++++++++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/config.ts b/src/config.ts index 56372ec..2303de6 100644 --- a/src/config.ts +++ b/src/config.ts @@ -33,7 +33,7 @@ export interface NotifierConfig { showProjectName: boolean showSessionTitle: boolean showIcon: boolean - notificationSystem: "osascript" | "node-notifier" + notificationSystem: "osascript" | "node-notifier" | "ghostty" linux: LinuxConfig command: CommandConfig events: { @@ -82,7 +82,7 @@ const DEFAULT_CONFIG: NotifierConfig = { showProjectName: true, showSessionTitle: false, showIcon: true, - notificationSystem: "osascript", + notificationSystem: "osascript" as const, linux: { grouping: false, }, @@ -210,7 +210,12 @@ export function loadConfig(): NotifierConfig { showProjectName: userConfig.showProjectName ?? DEFAULT_CONFIG.showProjectName, showSessionTitle: userConfig.showSessionTitle ?? DEFAULT_CONFIG.showSessionTitle, showIcon: userConfig.showIcon ?? DEFAULT_CONFIG.showIcon, - notificationSystem: userConfig.notificationSystem === "node-notifier" ? "node-notifier" : "osascript", + notificationSystem: + userConfig.notificationSystem === "node-notifier" + ? "node-notifier" + : userConfig.notificationSystem === "ghostty" + ? "ghostty" + : "osascript", linux: { grouping: typeof userConfig.linux?.grouping === "boolean" ? userConfig.linux.grouping : DEFAULT_CONFIG.linux.grouping, }, diff --git a/src/notify.ts b/src/notify.ts index 1d6a30e..ee2f618 100644 --- a/src/notify.ts +++ b/src/notify.ts @@ -85,7 +85,7 @@ export async function sendNotification( message: string, timeout: number, iconPath?: string, - notificationSystem: "osascript" | "node-notifier" = "osascript", + notificationSystem: "osascript" | "node-notifier" | "ghostty" = "osascript", linuxGrouping: boolean = true ): Promise { const now = Date.now() @@ -94,6 +94,16 @@ export async function sendNotification( } lastNotificationTime[message] = now + if (notificationSystem === "ghostty") { + return new Promise((resolve) => { + const escapedTitle = title.replace(/[;\x07\x1b]/g, "") + const escapedMessage = message.replace(/[;\x07\x1b]/g, "") + process.stdout.write(`\x1b]777;notify;${escapedTitle};${escapedMessage}\x07`, () => { + resolve() + }) + }) + } + if (platform === "Darwin") { if (notificationSystem === "node-notifier") { return new Promise((resolve) => {