Oct 28, '09 07:30:04AM • Contributed by: jaysoffian
It is often the case that I have a Safari window open in Space 1 (say), but I've switched to Space 2 to work on another task. I then need to open a URL from an application other than Safari while working on the Space 2 task. If Safari doesn't already have a window open in Space 2, but does have a window in Space 1, Safari opens the URL in a new tab in the window in Space 1. I would rather Safari open a new window in the current Space to handle the URL.
This is doable, but requires a little magic.
As a prerequisite, you'll need to install the RCDefaultApp preference pane.
- Open AppleScript Editor and paste in the following code:
- Save the document using file format Application, and select the Stay Open checkbox. Name it SafariURLHelper. I have an Applications folder in my home directory in which I saved it.
- Using the Finder, navigate to where you saved SafariURLHelper, then Control-click its icon and select Show Package Contents from the contextual menu.
- Inside the Contents folder, find Info.plist, and open it in a text editor.
- Add the following snippet to the bottom of the file, just before the closing </dict> and </plist> tags:
<key>CFBundleIdentifier</key> <string>com.apple.AppleScript.SafariURLHelper</string> <key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleURLName</key> <string>SafariURLHelper</string> <key>CFBundleURLSchemes</key> <array> <string>http</string> <string>https</string> </array> </dict> </array> <key>NSUIElement</key> <true/>A little bit of explanation. Most of the above text comes from this tip on macosxautomation.com, and just registers this application as something which can handle http and https links. The NSUIElement addition causes SafariURLHelper to be a background (faceless) application. - Save and close Info.plist, then in the Finder, double-click on SafariURLHelper. Nothing will appear to happen. This is fine; you've just launched SafariURLHelper as a hidden background process. More importantly, this registers it as a handler for http and https URLs.
- Open the Default Apps System Preferences pane. Click on the URLs tab, then set the default application for both http and https to SafariURLHelper (it should appear in the drop-down automatically).
