memo.xight.org

日々のメモ

Macでスクリプトからデスクトップ通知 (Displaying Notifications)

Summary

Macでスクリプトからデスクトップ通知を行う方法。
Apple Developer ではAppleSciprtとJavaScriptの例が挙げられている。

AppleScriptの例 (Apple Developer - Listing 24-1 より)

display notification "All graphics have been converted." with title "My Graphic Processing Script" subtitle "Processing is complete." sound name "Frog"

JavaScriptの例 (Apple Developer - Listing 24-2より)

var app = Application.currentApplication()

app.includeStandardAdditions = true

app.displayNotification("All graphics have been converted.", {
	withTitle: "My Graphic Processing Script",
	subtitle: "Processing is complete.",
	soundName: "Frog"
})


Reference

Mac Automation Scripting Guide: Displaying Notifications
https://developer.apple.com/library/content/documentation/LanguagesUtilities/Conceptual/MacAutomationScriptingGuide/DisplayNotifications.html