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) => {