Add linux notifications

This commit is contained in:
Saoud Rizwan 2024-12-18 11:39:47 -08:00
parent 4530e8f9e3
commit 6b1a48f2fb

View file

@ -50,6 +50,19 @@ async function showWindowsNotification(options: NotificationOptions): Promise<vo
}
}
async function showLinuxNotification(options: NotificationOptions): Promise<void> {
const { title = "", subtitle = "", message } = options
// Combine subtitle and message if subtitle exists
const fullMessage = subtitle ? `${subtitle}\n${message}` : message
try {
await execa("notify-send", [title, fullMessage])
} catch (error) {
throw new Error(`Failed to show Linux notification: ${error}`)
}
}
export async function showSystemNotification(options: NotificationOptions): Promise<void> {
try {
const { title = "Cline", message } = options
@ -65,6 +78,9 @@ export async function showSystemNotification(options: NotificationOptions): Prom
case "win32":
await showWindowsNotification({ ...options, title })
break
case "linux":
await showLinuxNotification({ ...options, title })
break
default:
throw new Error("Unsupported platform")
}