2014-09-04 168 views
0

我目前使用OSX10.10,需要使用MATLAB;但是因为他们没有更新应用程序来支持10.10,它会在启动时崩溃。到目前为止,我一直在使用pico编辑SystemVersion.plist [1](将版本从10.10更改为10.9)。除了每次我需要打开MATLAB并在每次关闭MATLAB时重新编辑它都非常烦人。自动编辑SystemVersion.plist

我想要做的是当我启动脚本时,它会将SystemVersion.plist编辑为正确的版本,以便我可以运行MATLAB而不会崩溃;然后当MATLAB退出时,它将版本从10.9重置为10.10)。我有一些代码(可能写得不好,我以前从未使用过苹果脚本);

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

回答

1

我有同样的做法,而是来到了此解决方案:(对于OS X Yosemite和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

需要对话框。延迟(以秒为单位)不会出于任何原因(我首先使用applescript解决matlab问题)。可能有另一种解决方案,但这对我有用。

,如果你使用的是带有Retina显示屏的Mac,您可能需要安装Java 7的运行环境,并替换为下面的做shell脚本的一部分:


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 &"

的图标还在做看起来有点低劣,但字体不再模糊。

我希望这可以帮助任何人在最近更新到优胜美地后面临问题。

jens

+0

这很好,但是,我发现我需要更改SystemVersion.plist的文件许可权以便脚本访问它。您正在使用哪个文件权限(我目前使用776-rwxrwxrw-;但这有点不安全) – Zongor 2014-10-19 14:46:03

+0

我已经添加了我的用户以在SystemVersion.plist上具有读取和写入权限。可能不是最好的解决方案,但是现在,直到MathWorks提出解决方案之前,我不知道该怎么做。有什么建议么? – Jens 2014-10-24 08:06:37