UPDATE:
ด้วย macOS 10.9 (Mavericks) และใหม่กว่าคุณสามารถโพสต์การแจ้งเตือนโดยใช้ AppleScript แบบธรรมดา:
theTitle <- "A Title"
theMsg <- "A message here"
cmd <- paste("osascript -e ", "'display notification ", '"', theMsg, '"', ' with title ', '"', theTitle, '"', "'", sep='')
system(cmd)
สิ่งนี้ทำให้ไม่จำเป็นต้องติดตั้งterminal-notifier
อ้างอิงด้านล่าง
-
ฉันได้ติดตั้งตัวแจ้งเทอร์มินัลไว้ใน Mac เพื่อรับการแจ้งเตือนทางเดสก์ท็อปจากบรรทัดคำสั่ง จากนั้นคุณสามารถสรุปการเรียกไปยังsystem()
คำสั่งเช่นนี้ (เปลี่ยนเส้นทางแน่นอน):
notify <- function(msgString='Message from R', titleString='Message from R', speakIt=FALSE) {
cmd <- paste('~/terminal-notifier/terminal-notifier.app/Contents/MacOS/terminal-notifier -message ', '"', msgString, '" -title "', titleString, '"', sep='')
system(cmd)
if (speakIt) {
system(paste('say', msgString))
}
}
คุณสามารถเรียกใช้ฟังก์ชันเช่นนี้
notify("R is done", "Message from R", speakIt=TRUE)
เพื่อรับข้อความเช่นนี้:

อัปเดต: รวมsay
คำสั่งของ @ VLC