当我的脚本在后台运行时,我想创建一个闪屏/活动对话框来通知用户发生了什么。我的脚本文件启动了一个本地应用程序的不同组件,其中包含一堆用户不需要看到/不会理解的单词。我知道如何让脚本在后台运行,但我想知道如何才能弹出对话框、新的终端窗口、通知或类似的内容,以便在每个组件启动后让用户知道。
例如,我有4个组件,因此该框会弹出并显示:
第1个组件(共4个)已成功启动。
第2个组件(共4个)已成功启动。
以此类推。
感谢任何帮助,因为我已经寻找了一段时间,但没有运气。要添加的一件事是,我能够使用以下代码打开一个新的终端窗口: /Applications/Utilities/Terminal.app/Contents/MacOS/Terminal &
这将是很好的,但是当我回显时,它仍然是第一个。
发布于 2018-12-18 11:02:16
您还可以通过启动通知消息来通知用户:
osascript -e 'display notification "hello"'
或者甚至是一个对话框,但这将等待用户单击"OK“按钮:
osascript -e 'display alert "Hello"'
示例:
#!/bin/bash
osascript -e 'display notification "Component 1 of 4 successfully started.." with title "in progress"'
sleep 2
osascript -e 'display notification "Component 2 of 4 successfully started.." with title "in progress"'
sleep 2
osascript -e 'display alert "Processing done."'
https://stackoverflow.com/questions/53822818
复制相似问题