editing com.apple.LaunchServices.plist to open Safari in 32-bit mode

This post is an continuation of my recent article on Safari 5.1 and 32-bit plugins: safari 5.1, HOD, java, and making them like each other. This post shows how to create/edit the LSArchitecturesForX86_64 key to tell Safari to run in 32bit or 64bit mode. This key is not created until the 32bit option is specified for Safari, weird I know, but then it persists across reboots, even if it is changed back to 64bit mode. The line we are interested in is <string>i386</string>, which specified 32bit, or X86_64 for 64bit.

An alternative to using the GUI to enable 32-bit mode for Safari is to use a bash script – this will also create the LSArchitecturesForX86_64 key regardless of whether the GUI method above has been used. The following bash code will edit the users’s com.apple.LaunchServices.plist file to set Safari to run in 32-bit mode. The data portion of the Safari array however, I am unable to script, Probably mostly because I don’t know how to get the string into hex format using the CLI. However this is the code I have ,  please drop me a line if you know how to get the data portion of the Safari array to write properly:

/usr/libexec/PListBuddy -c "Add :LSArchitecturesForX86_64 dict" ~/Library/Preferences/com.apple.LaunchServices.plist 
/usr/libexec/PListBuddy -c "Add LSArchitecturesForX86_64:com.apple.safari array" ~/Library/Preferences/com.apple.LaunchServices.plist
/usr/libexec/PListBuddy -c "Add LSArchitecturesForX86_64:com.apple.safari:array string i386" ~/Library/Preferences/com.apple.LaunchServices.plist

This code will create the following entry in the com.apple.launchservices.plist:

<key>LSArchitecturesForX86_64</key>
	<dict>
		<key>com.apple.Safari</key>
		<array>
			<string>i386</string>
		</array>
	</dict>

There’s also a <data> string that needs to go in the com.apple.Safari array. This should written using PListBuddy like so:

/usr/libexec/PListBuddy -c "Add LSArchitecturesForX86_64:com.apple.safari:array data fgskgsghjnsgskdjfnsdfbknsdjfgnsdfgk" ~/Library/Preferences/com.apple.LaunchServices.plist

This should create a data string in the com.apple.LaunchServices.plist file similar to the following, but there’s a problem with the string. I think it is hex formatting:

<data>
AAAAAACSAAMAAQAAxe6HnQAASCsAAAAAAE8RzwBR9QUAAMY7hBkA
AAAACSD//gAAAAAAAAAA/////wABAAQATxHPAA4AFgAKAFMAYQBm
AGEAcgBpAC4AYQBwAHAADwAMAAUATQBhAGMASABEABIAF0FwcGxp
Y2F0aW9ucy9TYWZhcmkuYXBwAAATAAEvAP//AAA=
</data>

You can view the hex formatting of this string using the defaults command:

ACMacBook:~ andrew$ defaults read com.apple.LaunchServices LSArchitecturesForX86_64
{
    "com.apple.Safari" =     (
        <00000000 00920003 00010000 c5ee879d 0000482b 00000000 004f11cf 0051f505 0000c63b 84190000 00000920 fffe0000 00000000 0000ffff ffff0001 0004004f 11cf000e 0016000a 00530061 00660061 00720069 002e0061 00700070 000f000c 0005004d 00610063 00480044 00120017 4170706c 69636174 696f6e73 2f536166 6172692e 61707000 00130001 2f00ffff 0000>,
        i386
);
}

However using PListBuddy to write 00000000 00920003, etc. ends in some very strange output in the LaunchServices plist file. In any case, a properly formed LSArchitecturesForX86_64 key, particular to Safari, looks like this:

	<key>LSArchitecturesForX86_64</key>
	<dict>
		<key>com.apple.Safari</key>
		<array>
			<data>
			AAAAAACSAAMAAQAAxe6HnQAASCsAAAAAAE8RzwBR9QUAAMY7hBkA
			AAAACSD//gAAAAAAAAAA/////wABAAQATxHPAA4AFgAKAFMAYQBm
			AGEAcgBpAC4AYQBwAHAADwAMAAUATQBhAGMASABEABIAF0FwcGxp
			Y2F0aW9ucy9TYWZhcmkuYXBwAAATAAEvAP//AAA=
			</data>
			<string>i386</string>
		</array>
	</dict>

The data string varies per machine model, so you will have to customize the data portion per model that this code/script will be run on.


About this entry