Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

### Fixed

- On WSL, toasts now work right after a fresh install or update, without a manual `chmod +x` on node-notifier's snoreToast executable (#152; issue #151).

### Contributors

- Thanks to @cardin for reporting and fixing the WSL toast issue in #152.

## [1.1.2] - 2026-11-01

### Fixed
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ For sounds, you need one of: `paplay`, `aplay`, `mpv`, or `ffplay`

**WSL**: Set `customIconPath` to a file on the Windows filesystem to avoid icon-path translation issues. You can copy an icon from this repository's `logos` folder. The path is passed to `snoretoast-*.exe`.

The plugin also restores the execute bit on node-notifier's bundled snoreToast executable when it loads, so a fresh install or update does not need a manual `chmod +x`.

In `opencode-notifier.json` config:

```json
Expand All @@ -83,7 +85,7 @@ In `opencode-notifier.json` config:
}
```

- If notifications are not showing up, check out: [missing WSL notification](https://github.com/mikaelbr/node-notifier?tab=readme-ov-file#windows-and-wsl2)
- If notifications are still not showing up, check out: [missing WSL notification](https://github.com/mikaelbr/node-notifier?tab=readme-ov-file#windows-and-wsl2)

## Config file

Expand Down
3 changes: 3 additions & 0 deletions src/notify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { getLinuxNotificationID, rememberLinuxNotificationID, sendLinuxActionNot
export { disposeLinuxNotifications } from "./notify-linux"
import notifier from "node-notifier"
import isWsl from "is-wsl"
import { ensureSnoreToastExecutable } from "./snoretoast"

const DEBOUNCE_MS = 1000

Expand All @@ -13,6 +14,8 @@ let platformNotifier: { notify(notification: notifier.Notification, callback: no

if (platform === "Windows_NT" || isWsl) {
const { WindowsToaster } = notifier
// npm ships the snoreToast executable without +x, which WSL needs to launch it.
if (isWsl) ensureSnoreToastExecutable()
platformNotifier = new WindowsToaster({ withFallback: false })
} else if (platform === "Linux" || platform.match(/BSD$/)) {
const { NotifySend } = notifier
Expand Down
26 changes: 26 additions & 0 deletions src/snoretoast.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { chmodSync, statSync } from "node:fs"
import { createRequire } from "node:module"
import { dirname, join } from "node:path"

function debug(message: string): void {
if (process.env.OPENCODE_NOTIFIER_DEBUG) console.error(`[opencode-notifier] snoreToast: ${message}`)
}

/**
* Called once at load on WSL. npm publishes node-notifier's snoreToast binaries
* without +x, WSL needs it to launch them, and node-notifier swallows the
* EACCES, so toasts fail silently. Adds +x like a manual `chmod +x` would.
* The x64/x86 pick mirrors node-notifier's notifiers/toaster.js. Never throws.
*/
export function ensureSnoreToastExecutable(): void {
try {
const root = dirname(createRequire(import.meta.url).resolve("node-notifier"))
const path = join(root, "vendor", "snoreToast", `snoretoast-x${process.arch === "x64" ? "64" : "86"}.exe`)
const { mode } = statSync(path)
if (mode & 0o100) return
chmodSync(path, mode | 0o111)
debug(`restored +x on ${path}`)
} catch (error) {
debug(`could not restore +x: ${String(error)}`)
}
}