I'm trying to use Automator to create a system-wide shortcut to open a new Safari window. I'm using the method described in this answer.
I can get Safari to open a specific url, for example by running
$ open -a Safari "https://apple.stackexchange.com"
From the command line. But this opens a new tab (not a new window) and requires specifying a URL.
Automator also has an "Internet > Display Webpages" action that has the same problems.
Is there a way to get Safari to open a new, blank window?
Best Answer
In Automator, create a Service workflow (pre macOS Mojave), or a Quick Action workflow in macOS Mojave.
Add a Run AppleScript action, replacing the default code, with:
The above piece of AppleScript code by itself will open a new window in Safari however, it will not have focus. If you want the new window to have focus then use a
tell
block, e.g.:You can then assign a keyboard shortcut in the usual manner per information in the link within your question.