@mohak34/opencode-notifier 0.1.34 → 0.1.35-beta.0
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/README.md +1 -1
- package/dist/index.js +65 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -123,7 +123,7 @@ Create `~/.config/opencode/opencode-notifier.json` with the defaults:
|
|
|
123
123
|
- `notification` - Turn notifications on/off (default: true)
|
|
124
124
|
- `timeout` - How long notifications show in seconds, Linux only (default: 5)
|
|
125
125
|
- `showProjectName` - Show folder name in notification title (default: true)
|
|
126
|
-
- `showSessionTitle` - Include the session title in notification messages via `{sessionTitle}` placeholder (default:
|
|
126
|
+
- `showSessionTitle` - Include the session title in notification messages via `{sessionTitle}` placeholder (default: false)
|
|
127
127
|
- `showIcon` - Show OpenCode icon, Windows/Linux only (default: true)
|
|
128
128
|
- `suppressWhenFocused` - Skip notifications and sounds when the terminal is the active window (default: true). See [Focus detection](#focus-detection) for platform details
|
|
129
129
|
- `enableOnDesktop` - Run the plugin on Desktop and Web clients (default: false). When false, the plugin only runs on CLI. Set to true if you want notifications/sounds/commands on Desktop/Web — useful if you want custom commands (Telegram, webhooks) but don't care about built-in notifications
|
package/dist/index.js
CHANGED
|
@@ -505,6 +505,23 @@ function runCommand2(config, event, message, sessionTitle, projectName, timestam
|
|
|
505
505
|
|
|
506
506
|
// src/focus.ts
|
|
507
507
|
import { execFileSync, execSync } from "child_process";
|
|
508
|
+
var MAC_TERMINAL_APP_NAMES = new Set([
|
|
509
|
+
"terminal",
|
|
510
|
+
"iterm2",
|
|
511
|
+
"ghostty",
|
|
512
|
+
"wezterm",
|
|
513
|
+
"alacritty",
|
|
514
|
+
"kitty",
|
|
515
|
+
"hyper",
|
|
516
|
+
"warp",
|
|
517
|
+
"tabby",
|
|
518
|
+
"cursor",
|
|
519
|
+
"visual studio code",
|
|
520
|
+
"code",
|
|
521
|
+
"code insiders",
|
|
522
|
+
"zed",
|
|
523
|
+
"rio"
|
|
524
|
+
]);
|
|
508
525
|
function execWithTimeout(command, timeoutMs = 500) {
|
|
509
526
|
try {
|
|
510
527
|
return execSync(command, { timeout: timeoutMs, encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
@@ -581,6 +598,44 @@ function getWindowsActiveWindowId() {
|
|
|
581
598
|
function getMacOSActiveWindowId() {
|
|
582
599
|
return execWithTimeout(`osascript -e 'tell application "System Events" to return id of window 1 of (first application process whose frontmost is true)'`);
|
|
583
600
|
}
|
|
601
|
+
function getMacOSFrontmostAppName() {
|
|
602
|
+
return execWithTimeout(`osascript -e 'tell application "System Events" to return name of first application process whose frontmost is true'`);
|
|
603
|
+
}
|
|
604
|
+
function normalizeMacAppName(value) {
|
|
605
|
+
return value.trim().toLowerCase().replace(/\.app$/i, "").replace(/\s+/g, " ");
|
|
606
|
+
}
|
|
607
|
+
function getExpectedMacTerminalAppNames(env) {
|
|
608
|
+
const expected = new Set;
|
|
609
|
+
const termProgram = typeof env.TERM_PROGRAM === "string" ? normalizeMacAppName(env.TERM_PROGRAM) : "";
|
|
610
|
+
if (termProgram === "apple_terminal") {
|
|
611
|
+
expected.add("terminal");
|
|
612
|
+
} else if (termProgram === "iterm" || termProgram === "iterm2") {
|
|
613
|
+
expected.add("iterm2");
|
|
614
|
+
} else if (termProgram === "vscode") {
|
|
615
|
+
expected.add("visual studio code");
|
|
616
|
+
expected.add("code");
|
|
617
|
+
expected.add("code insiders");
|
|
618
|
+
} else if (termProgram === "warpterminal") {
|
|
619
|
+
expected.add("warp");
|
|
620
|
+
} else if (termProgram.length > 0) {
|
|
621
|
+
expected.add(termProgram);
|
|
622
|
+
}
|
|
623
|
+
if (expected.size > 0) {
|
|
624
|
+
return expected;
|
|
625
|
+
}
|
|
626
|
+
return new Set(MAC_TERMINAL_APP_NAMES);
|
|
627
|
+
}
|
|
628
|
+
function isMacTerminalAppFocused(frontmostAppName, env = process.env) {
|
|
629
|
+
if (!frontmostAppName) {
|
|
630
|
+
return false;
|
|
631
|
+
}
|
|
632
|
+
const normalizedFrontmost = normalizeMacAppName(frontmostAppName);
|
|
633
|
+
if (!normalizedFrontmost) {
|
|
634
|
+
return false;
|
|
635
|
+
}
|
|
636
|
+
const expectedApps = getExpectedMacTerminalAppNames(env);
|
|
637
|
+
return expectedApps.has(normalizedFrontmost);
|
|
638
|
+
}
|
|
584
639
|
function getActiveWindowId() {
|
|
585
640
|
const platform3 = process.platform;
|
|
586
641
|
if (platform3 === "darwin")
|
|
@@ -609,6 +664,16 @@ function isTmuxPaneActive() {
|
|
|
609
664
|
}
|
|
610
665
|
function isTerminalFocused() {
|
|
611
666
|
try {
|
|
667
|
+
if (process.platform === "darwin") {
|
|
668
|
+
const frontmostAppName = getMacOSFrontmostAppName();
|
|
669
|
+
if (!isMacTerminalAppFocused(frontmostAppName, process.env)) {
|
|
670
|
+
return false;
|
|
671
|
+
}
|
|
672
|
+
if (process.env.TMUX) {
|
|
673
|
+
return isTmuxPaneActive();
|
|
674
|
+
}
|
|
675
|
+
return true;
|
|
676
|
+
}
|
|
612
677
|
if (!cachedWindowId)
|
|
613
678
|
return false;
|
|
614
679
|
const currentId = getActiveWindowId();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mohak34/opencode-notifier",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.35-beta.0",
|
|
4
4
|
"description": "OpenCode plugin that sends system notifications and plays sounds when permission is needed, generation completes, or errors occur",
|
|
5
5
|
"author": "mohak34",
|
|
6
6
|
"license": "MIT",
|