OSC 9 escape code does not display a toast notification, but they are in the notifications list when checked.
What Operating System(s) are you seeing this problem on?
macOS
Which Wayland compositor or X11 Window manager(s) are you using?
No response
WezTerm version
20240520-135708-b8f94c47
Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?
Yes, and I updated the version box above to show the version of the nightly that I tried
Describe the bug
I've tried sending the OSC 9 escape code from multple shells and devices and get no toasts. The first time I did get the MacOS allow notifications prompt and chose yes. If I click on the clock to show notifications they are there, but they never pop up as expected.
To Reproduce
send a notification with the OSC 9 escape sequence.
Configuration
no config
Expected Behavior
The notification will pop up under the clock, sound an alert, and dwell for a few seconds like all other notifications.
Logs
debug log is empty
Anything else?
When using the version from homebrew I didn't even get the hidden notifications. They started appearing when I tried on the nightly.
I had the same issue on MacOS with homebrew-installed WezTerm 20240203-110809-5046fc22.
What fixed it was going into MacOS Settings > Notifications > WezTerm and changing the notification type from "Banners" to "Alerts".
You can confirm that it works with e.g. printf "\e]9;%s\e\\" "hello there".
wezterm 20250624-071246-2deb317e
Not sure why, but on MacOS 15.3, None/Banners for the Allow Notifications doesn't show the popup for the printf, only in the Notification Center.
But it DOES work for:
window:toast_notification('wezterm', 'configuration reloaded!', nil, 4000)
The examples on the docs don't seem to work:
printf "\e]777;notify;%s;%s\e\\" "title" "body"
printf "\e]9;%s\e\\" "hello there"
But "Alerts" DOES show the notification, but Alerts is permanent.
My Wezterm notification settings:
Terminal notifier works fine..:
terminal-notifier -title "foo" -subtitle "bar" -message "baz":
My global notification settings:
For context, terminal-notifier's Notification settings:
adding the app explicitly to allowed apps in focus settings helped me. not sure if that is the case here :)
@shortpoet interesting! What's your MacOS version, and do the printf statements above work?
Tried playing around with adding it to focus (I never use focus anyway), and it still won't show.
Or was it this?
Also noticed:
I did something today I never wanted to do, and am shamed to admit it.
I looked at the Apple Developer Documentation -- https://developer.apple.com/documentation/usernotifications/unnotificationpresentationoptions
Noticed the options, did a quick search through and in /wezterm-toast-notification/src/macos.rs#L50-L52
let options =
UNNotificationPresentationOptions::List | UNNotificationPresentationOptions::Sound;
completion_handler.call((options,));
}
Needed to be:
let options = UNNotificationPresentationOptions::List
| UNNotificationPresentationOptions::Sound
| UNNotificationPresentationOptions::Banner;
This affects both OSC 9 escape code notifications and the Lua window:toast_notification() API, as they both go through the same macOS notification code path.
Technical Details
- List - Shows notification in Notification Center (was working)
- Sound - Plays notification sound (was working)
- Banner - Displays notification as a popup banner (was missing)
(Also needed to codesign to test, I do have a developer account for some reason).
Nice find @joshuataylor, feel free to open a PR 🙏