繁体   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