• 02Sep
    Categories: Apple, Development Comments Off

    I need a lot of desktop space as shown in the picture below.

    My Desktop

    Apart from my main hackintosh with dual 22″ monitors, I have a mac mini running linux with a 17″ monitor to the left for all my terminal work, and on the other side, I have a 17″ G4 iMac just for IRC. I have an RSS feed in one of my channels, so I tend to click on links in that, but Safari on the G4 isn’t the fastest thing around, so I decided to pull some Remote Apple Events tricks out of my hat so as to load links in Safari on my main machine instead.

    How I did it was to put the following into Applescript Editor, and save it as an Application Bundle (replacing the user, pass and ip/hostname in the second line) :

    on open location theurl
    	set dest to "eppc://user:pass@ipaddress"
    	tell application "Safari" of machine dest
    		activate
    		open location theurl
    	end tell
    end open location
    

    But for an application to handle URLs and be able to be set as the default browser, you have edit the Info.plist file inside the “Contents” folder of the app bundle and add the following:

    <key>CFBundleIdentifier</key>
    <string>com.pawz.openbrowser</string>
    <key>CFBundleURLTypes</key>
    <array>
    	<dict>
    		<key>CFBundleURLName</key>
    		<string>Remote Opener</string>
    		<key>CFBundleURLSchemes</key>
    		<array>
    			<string>http</string>
    		</array>
    	</dict>
    </array>
    

    Next, you have to tell OSX to refresh the launchservices info by running this command (which I’ve broken up into three commands just so it fits on this page) and replacing with the path to your app:

    cd /System/Library/Frameworks/CoreServices.framework
    cd Frameworks/LaunchServices.framework/Support
    ./lsregister -v -f /path/to/my.app
    

    Lastly you need to enable “Remote Apple Events” in the “Sharing” panel of System Preferences on your “destination” computer. Now, you can load up Safari on the “source” computer and change the default browser to be your Applescript application and close Safari again. Now, when you click on links in any application, it will contact the remote computer, bring Safari to the foreground, and load the URL. Isn’t that just *awesome* ?