linux通知中心标准,如何调用mac的通知中心(Notification Centers)做消息提醒

说说研究这个的起因:

妹子这几天心情不好,频发状态,为了随时了解她的动态,觉得写个接口时刻关注她是否发送新状态。mac下的通知中心是最好的消息提醒了,比ubuntu下的好多了,非常容易看到而且不烦人,所以想看看能不能调这个通知中心的接口。

系统编程肯定是可以了,但是我想用python写脚本,于是google一下,没有。改成英文找到了。。

几个关键的知识点:

osascript

https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/osascript.1.html

https://developer.apple.com/library/mac/documentation/AppleScript/Conceptual/AppleScriptX/AppleScriptX.html#//apple_ref/doc/uid/10000156-BCICHGIE

这应该是osx的系统级脚本语言,类似之前windows的vbscript吧。最早就用VBscript就能写界面程序,只要一个vbs脚本,学那个的时候才刚研究编程。

无需写个脚本,osascript有个-e参数,后面可以跟一个多行的脚本语句。就这个了。

想弹出一个提示,只要终端执行:osascript -e 'display notification "Content ! !" with title "Title"'

subtitle

display notification "message" with title "title" subtitle "subtitle"

sound声音

display notification "message" sound name "Sound Name"声音文件都在

~/Library/Sounds

/System/Library/Sounds

ok,直接python调一下语句就行了。后边两个是看stackoverflow上总结的,只管记录一下,以后说不定用到,应该问的也能查到。

通知中心的偏好设置里边,appscript编辑器必须在-在通知中心里边,这样才会有提示。

https://developer.apple.com/library/mac/documentation/AppleScript/Conceptual/AppleScriptLangGuide/reference/ASLR_cmds.html#//apple_ref/doc/uid/TP40000983-CH216-SW224

相关文章:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值