簡體   English   中英

自動編輯SystemVersion.plist

[英]Automating editing SystemVersion.plist

我目前正在使用OSX10.10,需要使用MATLAB; 但是,由於他們尚未將應用程序更新為支持10.10,因此它將在啟動時崩潰。

到目前為止,我一直在使用pico編輯SystemVersion.plist [1](將版本從10.10更改為10.9); 效果很好,除了每次打開MATLAB時都要編輯文件,而每次關閉MATLAB時都重新編輯文件確實很煩人。

我想做的是,當我啟動腳本時,它將SystemVersion.plist編輯為正確的版本,這樣我就可以在不崩潰的情況下運行MATLAB。 然后在MATLAB退出時將版本從10.9重置為10.10)。 我有一些代碼(可能寫得不好;我以前從未使用過applescript);

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]- 嘗試安裝JDK8 U11 OSX 10.10 Yosemite時出錯

我使用了相同的方法,但得出了以下解決方案:(適用於os x優勝美地和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問題)。 可能還有其他解決方案,但這對我有用。

如果您使用的是帶有視網膜顯示屏的Mac,則可能要安裝Java 7運行時環境,並用以下內容替換do 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 &"

圖標仍然看起來有些骯臟,但是字體不再模糊。

我希望這對最近更新到優勝美地的人有幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM