Tags: send/macnotifier
Tags
fix: handle stale notification clicks (#6) * fix: handle stale notification clicks without removing notifications Move NSApplication and delegate setup before -m validation so that when macOS relaunches the app for a notification click after the 60s timeout, the delegate can handle the click and execute actions from userInfo. This avoids the "macnotifier not found (-60)" error while keeping notifications visible in the notification center. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: handle -psn_* args from LaunchServices and reduce handler timeout - Ignore -psn_* arguments that LaunchServices passes when launching .app - Track hasUserFlags to distinguish "launched by notification click" from "user forgot -m" - Reduce notification-click handler timeout from 5s to 2s Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * docs: mention no-args notification-click handler in usage text Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: use cancelable DispatchWorkItem and derive hasUserFlags from args - didReceive cancels the termination timer to avoid racing with the 2s fallback timeout in notification-click handler mode - Derive hasUserFlags by checking for non -psn_* arguments instead of setting it in each switch case, preventing accidental omission Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: dispatch terminationWork cancel to main thread to avoid data race Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: cancel terminationWork directly for immediate effect DispatchWorkItem.cancel() is thread-safe and the variable is written once before app.run(), so direct cancellation is safe and ensures the timer is cancelled before didReceive returns. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
fix: don't delete temp icon file before notification is enqueued (#5) * fix: don't delete temp icon file before notification is enqueued UNNotificationAttachment init only records the file path; the actual file move happens during center.add(). Removing the temp directory immediately after init deleted the file before it could be moved, causing "Failed to move attachment file into data store". Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: use fixed temp directory for icon attachment Use a single reusable directory (sh.send.macnotifier) instead of per-notification UUID directories to avoid accumulation in /tmp. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: use UUID filename and clean up old icon copies on each notification Avoid race conditions between concurrent processes by using unique filenames, while cleaning up previous copies best-effort before creating new ones. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
fix: improve app activation and fix icon attachment (#4) * fix: use NSRunningApplication.activate() and copy icon to temp for attachment - Use NSRunningApplication.activate() for already-running apps instead of NSWorkspace.open(url), which is unreliable for bringing apps to foreground - Copy icon file to a temporary directory before creating UNNotificationAttachment, since the system moves (consumes) the file into its data store, deleting the original Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: extract createIconAttachment to fix function_body_length lint Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: dispatch app activation to main thread UNUserNotificationCenterDelegate callbacks are not guaranteed to run on the main thread, but NSRunningApplication/AppKit APIs require it. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: clean up temporary directory after creating icon attachment Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: fall back to NSWorkspace.open when activate() returns false Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
feat: support reading message from stdin When -m is omitted and stdin is a pipe, the message is read from stdin. This enables usage like: echo "hello" | macnotifier -t "Title" Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>