2014-09-04 164 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