dondon-notify 0.1.2 → 0.1.3
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 +11 -4
- package/test/test-kitty.js +13 -8
package/package.json
CHANGED
package/src/notify.ts
CHANGED
|
@@ -258,7 +258,12 @@ async function getFrontmostApp(): Promise<string | null> {
|
|
|
258
258
|
|
|
259
259
|
async function detectTerminalInfo(config: NotifyConfig): Promise<TerminalInfo> {
|
|
260
260
|
// Use config override if provided
|
|
261
|
-
|
|
261
|
+
let terminalName = config.terminal || detectTerminal() || null
|
|
262
|
+
|
|
263
|
+
// Normalize Kitty name (often xterm-kitty)
|
|
264
|
+
if (terminalName?.toLowerCase().includes("kitty")) {
|
|
265
|
+
terminalName = "kitty"
|
|
266
|
+
}
|
|
262
267
|
|
|
263
268
|
if (!terminalName) {
|
|
264
269
|
return { name: null, bundleId: null, processName: null, windowId: null }
|
|
@@ -353,8 +358,8 @@ interface NotificationOptions {
|
|
|
353
358
|
function sendNotification(options: NotificationOptions): void {
|
|
354
359
|
const { title, message, sound, terminalInfo } = options
|
|
355
360
|
|
|
356
|
-
// Use Kitty notifications if available
|
|
357
|
-
if (terminalInfo.name?.toLowerCase() === "kitty"
|
|
361
|
+
// Use Kitty notifications if available
|
|
362
|
+
if (terminalInfo.name?.toLowerCase() === "kitty") {
|
|
358
363
|
// Use default Kitty settings (simpler approach)
|
|
359
364
|
sendKittyNotification({
|
|
360
365
|
title,
|
|
@@ -366,10 +371,12 @@ function sendNotification(options: NotificationOptions): void {
|
|
|
366
371
|
}
|
|
367
372
|
|
|
368
373
|
// Fall back to system notifications
|
|
369
|
-
const notifyOptions:
|
|
374
|
+
const notifyOptions: any = {
|
|
370
375
|
title,
|
|
371
376
|
message,
|
|
372
377
|
sound,
|
|
378
|
+
appName: "OpenCode",
|
|
379
|
+
id: "opencode-notify",
|
|
373
380
|
}
|
|
374
381
|
|
|
375
382
|
// macOS-specific: click notification to focus terminal
|
package/test/test-kitty.js
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* This script will test the Kitty-specific features we've added
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
import { execSync } from 'node:child_process'
|
|
9
|
+
import process from 'node:process'
|
|
9
10
|
|
|
10
11
|
console.log('Testing Kitty notification improvements...\n')
|
|
11
12
|
|
|
@@ -40,8 +41,8 @@ console.log('\n4. Platform Detection:')
|
|
|
40
41
|
console.log(` Platform: ${process.platform}`)
|
|
41
42
|
console.log(` Architecture: ${process.arch}`)
|
|
42
43
|
|
|
43
|
-
// Test
|
|
44
|
-
console.log('\
|
|
44
|
+
// Test 6: Test if we can detect focus (simplified)
|
|
45
|
+
console.log('\n6. Focus Detection Test:')
|
|
45
46
|
if (process.platform === 'linux' && windowId) {
|
|
46
47
|
console.log(` Would test focus detection for Kitty window ${windowId}`)
|
|
47
48
|
console.log(` (This would use xprop to check _NET_ACTIVE_WINDOW)`)
|
|
@@ -51,23 +52,27 @@ if (process.platform === 'linux' && windowId) {
|
|
|
51
52
|
console.log(` Focus detection not available on this platform`)
|
|
52
53
|
}
|
|
53
54
|
|
|
54
|
-
console.log('\
|
|
55
|
-
if (isKitty
|
|
55
|
+
console.log('\n7. Kitty Notification Test:')
|
|
56
|
+
if (isKitty) {
|
|
56
57
|
console.log(' Sending test notification via Kitty OSC 99...')
|
|
57
58
|
|
|
58
59
|
try {
|
|
59
60
|
// Send a test Kitty notification
|
|
60
61
|
const title = 'OpenCode Notify Test'
|
|
61
62
|
const message = 'Kitty notification integration working!'
|
|
62
|
-
const escapeSequence = `\x1b]99;i=1:d=1;p=title;${title}\x1b\\\x1b]99;i=1:d=1;p=body;${message}\x1b\\`
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
// Protocol: \x1b]99;<metadata>;<payload>\x1b\\
|
|
65
|
+
// Metadata: d=0 means more follows, d=1 means done
|
|
66
|
+
const titleSeq = `\x1b]99;i=1:d=0:p=title;${title}\x1b\\`
|
|
67
|
+
const bodySeq = `\x1b]99;i=1:d=1:p=body;${message}\x1b\\`
|
|
68
|
+
|
|
69
|
+
process.stdout.write(titleSeq + bodySeq)
|
|
65
70
|
console.log(' ✓ Test notification sent!')
|
|
66
71
|
} catch (error) {
|
|
67
72
|
console.log(` ✗ Failed to send test notification: ${error.message}`)
|
|
68
73
|
}
|
|
69
74
|
} else {
|
|
70
|
-
console.log(' Skipping - not in Kitty
|
|
75
|
+
console.log(' Skipping - not in Kitty')
|
|
71
76
|
}
|
|
72
77
|
|
|
73
78
|
console.log('\nTest completed!')
|