脚本如下
property theCurrentURL : ""
tell application "Google Chrome"
set theCurrentURL to URL of active tab of window 1
close active tab of window 1
end tell
tell application "Terminal"
do script "/usr/local/Cellar/mpv/0.17.0/bin/mpv " & theCurrentURL
end tell
现在能够自动打开当前网页视频在 mpv 播放,然后关闭视频网页。
需要求助的问题是,每次运行都会打开一个终端窗口,需要手动关闭很繁琐,那么怎样让每次播放完毕或者退出 mpv 时自动关闭本次打开的终端?
- 想到的解决办法是 AppleScript 判断命令执行情况然后决定是否关闭终端,但是搜了一圈不知道怎么做
- 或者通过判断 mpv 进程运行情况,决定是否关闭终端,需要延时判断,否则一开始就会执行退出,但感觉遇到缓存时间过久,延时便不适用