【问题标题】:Notification when Terminal is ready/finished - Applescript终端准备好/完成时的通知 - Applescript
【发布时间】:2013-04-22 17:46:51
【问题描述】:

有没有办法在终端完成命令时得到通知?

-> 我运行另一个脚本(不是我的!),该脚本完成后下载数据我想退出终端并用这些数据做其他事情。

编辑:
我可能没问对...

例子:


tell application "Terminal"
   keystroke "php downloadscript.php"
   keystroke return
end tell

if (downloadFinished) -- do stuff else -- wait till finished

编辑 2: 惊人的!谢谢! 像这样工作:


tell application "Terminal"
    set frontWindow to window 1
    repeat until busy of frontWindow is false
        delay 1
    end repeat
    #display dialog "finished"
end tell
你好 哈士奇

【问题讨论】:

    标签: macos notifications terminal applescript


    【解决方案1】:

    当标签打印 \a 并且标签没有聚焦或终端不在最前面时,终端的 Dock 图标开始弹跳:

    sleep 5; printf '\a'
    

    你也可以运行类似afplay /System/Library/Sounds/Blow.aiff 的东西。或者使用终端通知器:

    sudo gem install terminal-notifier
    terminal-notifier -message ''
    

    您可以通过检查选项卡的忙属性等到程序完成运行:

    tell application "Terminal"
        set w to do script "sleep 5"
        repeat
            delay 1
            if not busy of w then exit repeat
        end repeat
    end tell
    

    【讨论】:

    • 有没有办法在applescript中捕捉到这个通知就像 if gotNotificationMessage //do stuff
    • @Timm 你可以只检查标签是否正忙于 AppleScript。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多