Use osascript to send macOS system notifications.
Use Cases
- Notify the user after a long-running task is completed
- Scheduled reminders
- Important messages that need to draw the user's attention
Command Reference
Send a basic notification
osascript -e 'display notification "任务已完成" with title "小搭子"'
Notification with subtitle
osascript -e 'display notification "3 个文件已整理完毕" with title "小搭子" subtitle "文件整理"'
Notification with sound
osascript -e 'display notification "注意:操作需要确认" with title "小搭子" sound name "default"'
Popup dialog (requires user response)
osascript -e 'display dialog "确认删除这 5 个文件吗?" with title "小搭子" buttons {"取消", "删除"} default button "取消"'
Usage Guidelines
- The notification title should always be "小搭子"
- Notification content should be concise and no more than one line
- Only send notifications in the following scenarios:
- When a task taking > 10 seconds is completed
- Errors or warnings that require the user's attention
- When a scheduled task is triggered
- Do not send notifications frequently (at most 1 completion notification per task)