0

I am currently using OSX10.10 and need to use MATLAB; however because they haven't updated the application to support 10.10 it will crash on launch.

Up until now I have been using pico to edit the SystemVersion.plist [1] (changing the version from 10.10 to 10.9); and that works great except that it is really annoying to edit the file every time I need to open MATLAB and re-edit it every time I close MATLAB.

What I want to do is when I start the script it will edit the SystemVersion.plist to the correct version so that I can run MATLAB without it crashing; and then when MATLAB exits it resets the version back from 10.9 to 10.10). I have a bit of code (which may be poorly written; I have never used applescript before);

tell application "System Events"
set ProcessList to name of every process
       if "MATLAB" is in ProcessList then
            tell application "System Events"
            tell property list file "/System/Library/CoreServices/SystemVersion.plist"
                tell contents
                    set value of property list item "ProductUserVisibleVersion" to "10.9"
                    set value of property list item "ProductVersion" to "10.9"
                end tell
            end tell
        end tell

        else

            tell application "System Events"
            tell property list file "/System/Library/CoreServices/SystemVersion.plist"
                 tell contents
                    set value of property list item "ProductUserVisibleVersion" to "10.10"
                        set value of property list item "ProductVersion" to "10.10"
                 end tell
               end tell
            end tell    
       end if
  end tell

[1] - Error trying to installing JDK8 U11 OSX 10.10 Yosemite

4

1 回答 1

1

I had the same approach, but came down to this solution: (for os x yosemite and matlab r2014a)

tell application "System Events"
    set plistFile to property list file "/System/Library/CoreServices/SystemVersion.plist"
    tell plistFile
        get property list item "ProductVersion"
        set value of property list item "ProductVersion" to "10.90"
    end tell
end tell

do shell script "export MATLAB_USE_USERWORK=1" & ";/Applications/MATLAB_R2014a.app/bin/matlab -desktop &> /dev/null &"

display dialog "..." buttons {"Ok"} with icon note giving up after 10

tell application "System Events"
    set plistFile to property list file "/System/Library/CoreServices/SystemVersion.plist"
    tell plistFile
        get property list item "ProductVersion"
        set value of property list item "ProductVersion" to "10.10"
    end tell
end tell

the dialog box is needed. delay (in seconds) does not do it for any reasons (i first used applescript to solve the matlab problem). there might be another solution, but this works for me.

if you are using a mac with retina display, you may want to install an java 7 runtime environment and replace the do shell script part with the following:


do shell script "export MATLAB_JAVA=\"/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home\"" & "; export MATLAB_USE_USERWORK=1" & ";/Applications/MATLAB_R2014a.app/bin/matlab -desktop &> /dev/null &"

the icons still do look a little shitty, but the fonts aren't blurry anymore.

i hope this may help anybody facing the problem after updating to yosemite lately.

jens

于 2014-10-18T11:45:52.587 回答