dondon-notify 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/notify.ts +19 -18
package/package.json
CHANGED
package/src/notify.ts
CHANGED
|
@@ -218,30 +218,31 @@ interface KittyNotificationOptions {
|
|
|
218
218
|
|
|
219
219
|
function sendKittyNotification(options: KittyNotificationOptions): void {
|
|
220
220
|
const { title, message, sound, focusOnClick = true } = options
|
|
221
|
-
|
|
221
|
+
|
|
222
222
|
try {
|
|
223
|
-
// Build Kitty OSC 99 notification
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
//
|
|
223
|
+
// Build Kitty OSC 99 notification
|
|
224
|
+
// Protocol: \x1b]99;<metadata>;<payload>\x1b\\
|
|
225
|
+
// Metadata is colon-separated key=value pairs
|
|
226
|
+
// d=0 means more data coming, d=1 means done
|
|
227
|
+
|
|
228
|
+
const baseParts = ["i=1"]
|
|
227
229
|
if (focusOnClick) {
|
|
228
|
-
|
|
230
|
+
baseParts.push("a=focus")
|
|
229
231
|
}
|
|
230
|
-
|
|
231
|
-
// Add sound if configured ( Kitty supports some sound names)
|
|
232
232
|
if (sound && sound !== "silent") {
|
|
233
|
-
|
|
233
|
+
baseParts.push(`s=${sound}`)
|
|
234
234
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
const
|
|
238
|
-
const
|
|
239
|
-
|
|
240
|
-
//
|
|
241
|
-
const
|
|
242
|
-
|
|
235
|
+
|
|
236
|
+
// Title message (d=0 = not done, more coming)
|
|
237
|
+
const titleMeta = [...baseParts, "d=0", "p=title"].join(":")
|
|
238
|
+
const titleSeq = `\x1b]99;${titleMeta};${title}\x1b\\`
|
|
239
|
+
|
|
240
|
+
// Body message (d=1 = done)
|
|
241
|
+
const bodyMeta = [...baseParts, "d=1", "p=body"].join(":")
|
|
242
|
+
const bodySeq = `\x1b]99;${bodyMeta};${message}\x1b\\`
|
|
243
|
+
|
|
243
244
|
// Send to stdout
|
|
244
|
-
process.stdout.write(
|
|
245
|
+
process.stdout.write(titleSeq + bodySeq)
|
|
245
246
|
} catch (error) {
|
|
246
247
|
// Fall back to system notification if Kitty notification fails
|
|
247
248
|
console.warn("Kitty notification failed, falling back to system notification:", error)
|