Error: Can't open display: (null) Failed creating new xdo instance on mac OS

Error: Can't open display: (null) Failed creating new xdo instance on mac OS

我在网上看了很多答案,但没有任何解决方案有帮助。 当我只执行 open http://google.com 时,我的默认浏览器是 Google Chrome。我通过 brew 下载了 xdotool 包 我想要做的是,打开网页(任何网页)并每 10 秒刷新一次,我有以下代码:

#!/bin/bash
while true;
do
    export DISPLAY=:0.0
    export XAUTHORITY=/home/dogaister/.Xauthority
    open  http://google.com
    xdotool key command+r
    sleep 10
done

我也试过DISPLAY=':0'DISPLAY=':0.0',他们也没用。

#!/bin/bash
while true;
do
    osascript -e 'tell application "Google Chrome" to reload (tabs of window 1 whose URL contains "google.ca")'
    sleep 10
    echo "Reloaded"
done

成功了。感谢 Mark Setchell 的贡献