Error: Can't Open Display: (Null) Failed Creating New Xdo Instance on Mac Os

I looked at many answers on internet but no solutions helped. When I just do open it works, my default browser is Google Chrome. I downloaded xdotool package via brew What I want to do is, to open the webpage(any webpage) and refresh it in every 10 seconds, I have the following code:

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

I also tried DISPLAY=':0' or DISPLAY=':0.0', they didn't work either.

6

1 Answer

#!/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

worked. Thanks to Mark Setchell for his contribution

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Elena Rostova

Elena Rostova

Lead Health, Wellness & Medical Journalist

Elena Rostova holds a Master's degree in Public Health Journalism. She covers groundbreaking medical research, holistic wellness trends, mental health awareness, and nutritional science.

Share this article
Twitter Facebook Pinterest