Skip to content

Comments

nsuser: replace deprecated NSUserNotification with osascript display notification#168

Open
munyari wants to merge 1 commit intovariadico:mainfrom
munyari:main
Open

nsuser: replace deprecated NSUserNotification with osascript display notification#168
munyari wants to merge 1 commit intovariadico:mainfrom
munyari:main

Conversation

@munyari
Copy link

@munyari munyari commented Feb 14, 2026

Apple removed NSUserNotification in macOS 13 (Ventura). Since then, noti's macOS banner notifications have been silently failing.

This change replaces the Objective-C CGO implementation with a pure Go implementation that shells out to osascript -e 'display notification ...'. This is the same mechanism the user would invoke manually from the terminal and works on all current macOS versions.

The old implementation used method swizzling to override NSBundle.bundleIdentifier (spoofing com.apple.terminal) and ran an NSRunLoop to wait for delivery confirmation. None of that machinery is needed with osascript, which handles delivery.

Changes:

  • Remove nsuser_darwin.h (Objective-C CGO bridge)
  • Rewrite nsuser_darwin.go as pure Go using os/exec
  • Escape backslashes, double quotes, and control characters (newlines, tabs, carriage returns) in AppleScript strings to prevent injection and syntax errors
  • Log a warning when ContentImage is set, since display notification does not support custom images (feature regression, but NSUserNotification's image support was apparently broken on recent macOS)
  • Remove the darwin-specific Makefile release target; the wildcard rule with CGO_ENABLED=0 now covers darwin since CGO is no longer needed
  • Add unit tests for escapeAS and buildScript

@munyari munyari changed the title nsuser: replace deprecated NSUserNotification with osascript display … nsuser: replace deprecated NSUserNotification with osascript display notifiction Feb 14, 2026
@munyari munyari changed the title nsuser: replace deprecated NSUserNotification with osascript display notifiction nsuser: replace deprecated NSUserNotification with osascript display notification Feb 14, 2026
…notification

Apple removed NSUserNotification in macOS 13 (Ventura). Since then,
noti's macOS banner notifications have been silently failing.

This change replaces the Objective-C CGO implementation with a pure Go
implementation that shells out to `osascript -e 'display notification
...'`. This is the same mechanism the user would invoke manually from
the terminal and works on all current macOS versions.

The old implementation used method swizzling to override
`NSBundle.bundleIdentifier` (spoofing `com.apple.terminal`) and ran an
`NSRunLoop` to wait for delivery confirmation. None of that machinery
is needed with osascript, which handles delivery.

Changes:

- Remove nsuser_darwin.h (Objective-C CGO bridge)
- Rewrite nsuser_darwin.go as pure Go using os/exec
- Escape backslashes, double quotes, and control characters (newlines,
  tabs, carriage returns) in AppleScript strings to prevent injection
  and syntax errors
- Log a warning when `ContentImage` is set, since display notification
  does not support custom images (feature regression, but
  `NSUserNotification`'s image support was apparently broken on recent
  macOS)
- Remove the darwin-specific Makefile release target; the wildcard
  rule with `CGO_ENABLED=0` now covers darwin since CGO is no longer
  needed
- Add unit tests for `escapeAS` and `buildScript`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant