New Safari window if none is visible in the current Space

I'm a regular Spaces user and for the longest time I've been annoyed – very annoyed – by the fact that, when clicking on the Safari icon in the Dock from a Space where there are no browser windows open, either the Space is swapped with a different one where there's a Safari window open (if I have the "When switching application, jump to a Space with application windows open" setting enabled in System Preferences > Mission Control), or Safari activates, but with no window until I hit CMD+N (if that setting is off).

In the past I made Applescript-compiled apps to hack around this behavior, but they were complicated and not entirely reliable, so I kept living with this major frustration.

Today, the rug was swept under my feet for the last time, as I've figured I could put together something in Keyboard Maestro, and less than 5 minutes later I had a simple and so far reliable solution:

This is working well for me with the "When switching application, jump to a Space with application windows open" setting disabled... so I thought I'd share because maybe I can help someone else's blood pressure to stay within proper limits :wink:

New Safari window if none is visible in the current Space.kmmacros (2,6 KB)

3 Likes

Hi @cdf1982. Thanks for sharing!

I'm also a regular user of Mission Control Desktop Spaces and have been using the same action, but within a macro that I launch via Hot Key or Conflict Palette. When I open Safari via these two Keyboard Maestro triggers, I similarly force Safari to open a new window in the active space. (I have similar macros for the other browsers I use.)

Contrastingly, I've enabled When switching application, jump to a Space with application windows open enabled. That way when I launch Safari using standard methods (Spotlight, Dock, LaunchBar, etc.) the space automatically changes to the one that includes the most recently opened Safari window. I could see how this might be aggravating for some, but I personally like the flexibility that this affords.


@cdf1982, have you been similarly annoyed by the Finder. If so, you might like this macro subroutine:

DOWNLOAD Macro Subroutine File:
𝗌.𝗳𝗻𝗱⇾NewFinderTabInSpace.kmmacros (29 KB)

Macro Subroutine-image

It can be be triggered directly or with a calling macro action, e.g.,

Keyboard Maestro Export


Finally, @cdf1982, you might find these two posts interesting: