@mohak34/opencode-notifier 0.1.30-beta.3 → 0.1.30-beta.5

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.
Files changed (3) hide show
  1. package/README.md +16 -4
  2. package/dist/index.js +26 -11
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -123,7 +123,7 @@ Create `~/.config/opencode/opencode-notifier.json` with the defaults:
123
123
  - `showSessionTitle` - Include the session title in notification messages via `{sessionTitle}` placeholder (default: true)
124
124
  - `showIcon` - Show OpenCode icon, Windows/Linux only (default: true)
125
125
  - `suppressWhenFocused` - Skip notifications and sounds when the terminal is the active window (default: true). See [Focus detection](#focus-detection) for platform details
126
- - `notificationSystem` - macOS only: `"osascript"` or `"node-notifier"` (default: "osascript")
126
+ - `notificationSystem` - macOS only: `"osascript"`, `"node-notifier"`, or `"ghostty"` (default: "osascript"). Use `"ghostty"` if you're running Ghostty terminal for native OSC 777 notifications
127
127
  - `linux.grouping` - Linux only: replace notifications in-place instead of stacking (default: false). Requires `notify-send` 0.8+
128
128
 
129
129
  ### Events
@@ -177,7 +177,7 @@ Messages support placeholder tokens that get replaced with actual values:
177
177
  - `{sessionTitle}` - The title/summary of the current session (e.g. "Fix login bug")
178
178
  - `{projectName}` - The project folder name
179
179
  - `{timestamp}` - Current time in `HH:MM:SS` format (e.g. "14:30:05")
180
- - `{turn}` - Notification counter for the session, increments with each notification (e.g. 1, 2, 3)
180
+ - `{turn}` - Global notification counter that persists across restarts (e.g. 1, 2, 3). Stored in `~/.config/opencode/opencode-notifier-state.json`
181
181
 
182
182
  When `showSessionTitle` is `false`, `{sessionTitle}` is replaced with an empty string. Any trailing separators (`: `, ` - `, ` | `) are automatically cleaned up when a placeholder resolves to empty.
183
183
 
@@ -230,7 +230,7 @@ Set per-event volume from `0` to `1`:
230
230
 
231
231
  ### Custom commands
232
232
 
233
- Run your own script when something happens. Use `{event}`, `{message}`, and `{sessionTitle}` as placeholders:
233
+ Run your own script when something happens. Use `{event}`, `{message}`, `{sessionTitle}`, `{projectName}`, `{timestamp}`, and `{turn}` as placeholders:
234
234
 
235
235
  ```json
236
236
  {
@@ -245,7 +245,7 @@ Run your own script when something happens. Use `{event}`, `{message}`, and `{se
245
245
 
246
246
  - `enabled` - Turn command on/off
247
247
  - `path` - Path to your script/executable
248
- - `args` - Arguments to pass, can use `{event}`, `{message}`, and `{sessionTitle}` tokens
248
+ - `args` - Arguments to pass, can use `{event}`, `{message}`, `{sessionTitle}`, `{projectName}`, `{timestamp}`, and `{turn}` tokens
249
249
  - `minDuration` - Skip if response was quick, avoids spam (seconds)
250
250
 
251
251
  #### Example: Log events to a file
@@ -283,6 +283,18 @@ Run your own script when something happens. Use `{event}`, `{message}`, and `{se
283
283
 
284
284
  **NOTE:** If you go with node-notifier and start missing notifications, just switch back or remove the option from the config. Users have reported issues with using node-notifier for receiving only sounds and no notification popups.
285
285
 
286
+ ## Ghostty notifications
287
+
288
+ If you're using [Ghostty](https://ghostty.org/) terminal, you can use its native notification system via OSC 777 escape sequences:
289
+
290
+ ```json
291
+ {
292
+ "notificationSystem": "ghostty"
293
+ }
294
+ ```
295
+
296
+ This sends notifications directly through the terminal instead of using system notification tools. Works on any platform where Ghostty is running.
297
+
286
298
  ## Focus detection
287
299
 
288
300
  When `suppressWhenFocused` is `true` (the default), notifications and sounds are skipped if the terminal running OpenCode is the active/focused window. The idea is simple: if you're already looking at it, you don't need an alert.
package/dist/index.js CHANGED
@@ -4319,6 +4319,16 @@ function isPidAncestorOfProcess(targetPid, startPid) {
4319
4319
  function isFocusedWindowOurs(windowPid) {
4320
4320
  return isPidAncestorOfProcess(windowPid, getProcessTreeRoot());
4321
4321
  }
4322
+ var tmuxPane = process.env.TMUX_PANE ?? null;
4323
+ function isTmuxPaneActive() {
4324
+ if (!tmuxPane)
4325
+ return true;
4326
+ const result = execWithTimeout(`tmux display-message -t ${tmuxPane} -p '#{session_attached} #{window_active} #{pane_active}'`);
4327
+ if (!result)
4328
+ return false;
4329
+ const [sessionAttached, windowActive, paneActive] = result.split(" ");
4330
+ return sessionAttached === "1" && windowActive === "1" && paneActive === "1";
4331
+ }
4322
4332
  function isLinuxX11Focused() {
4323
4333
  const pidStr = execWithTimeout("xdotool getactivewindow getwindowpid");
4324
4334
  if (!pidStr)
@@ -4441,25 +4451,30 @@ Write-Output $pid
4441
4451
  function isTerminalFocused() {
4442
4452
  try {
4443
4453
  const platform3 = process.platform;
4454
+ let windowFocused = false;
4444
4455
  if (platform3 === "darwin") {
4445
4456
  const terminal = detectTerminal();
4446
4457
  if (!terminal || terminal.macProcessNames.length === 0)
4447
4458
  return false;
4448
- return isMacOSFocused(terminal);
4449
- }
4450
- if (platform3 === "linux") {
4459
+ windowFocused = isMacOSFocused(terminal);
4460
+ } else if (platform3 === "linux") {
4451
4461
  if (process.env.WAYLAND_DISPLAY) {
4452
- return isLinuxWaylandFocused();
4453
- }
4454
- if (process.env.DISPLAY) {
4455
- return isLinuxX11Focused();
4462
+ windowFocused = isLinuxWaylandFocused();
4463
+ } else if (process.env.DISPLAY) {
4464
+ windowFocused = isLinuxX11Focused();
4465
+ } else {
4466
+ return false;
4456
4467
  }
4468
+ } else if (platform3 === "win32") {
4469
+ windowFocused = isWindowsFocused();
4470
+ } else {
4457
4471
  return false;
4458
4472
  }
4459
- if (platform3 === "win32") {
4460
- return isWindowsFocused();
4461
- }
4462
- return false;
4473
+ if (!windowFocused)
4474
+ return false;
4475
+ if (process.env.TMUX)
4476
+ return isTmuxPaneActive();
4477
+ return true;
4463
4478
  } catch {
4464
4479
  return false;
4465
4480
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mohak34/opencode-notifier",
3
- "version": "0.1.30-beta.3",
3
+ "version": "0.1.30-beta.5",
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",