How do I set plist values

岁酱吖の 提交于 2019-12-10 12:07:25

问题


I am trying to change some Safari settings and am trying to use com.apple.Safari.plist for this.
These are the following key values I need to change

com.apple.Safari.ContentPageGroupIdentifier.WebKit2JavaScriptEnabled
WebKitJavaScriptEnabled
com.apple.Safari.ContentPageGroupIdentifier.WebKit2JavaScriptCanOpenWindowsAutomatically
WebKitJavaScriptCanOpenWindowsAutomatically
com.apple.Safari.ContentPageGroupIdentifier.WebKit2PluginsEnabled
WebKitPluginsEnabled
WebKitJavaEnabled

I tried changing the first one using

defaults write com.apple.Safari.ContentPageGroupIdentifier.WebKit2JavaScriptEnabled -bool true

It did not change values. I need some help to understand why and how to rectify that.

And also I would like some help on how to access this value to change the string value

<key>ManagedPlugInPolicies</key>
<dict>
    <key>PlugInName</key>
    <dict>
        <key>PlugInDisallowPromptBeforeUseDialog</key>
        <true/>
        <key>PlugInFirstVisitPolicy</key>
        <string>PlugInPolicyAllowNoSecurityRestrictions</string>
    </dict>
</dict>

How do I change the value of PlugInFirstVisitPolicy? I want to change the string to something else.

Is there another way than defaults write. I've read about plistbuddy but am not sure how to use it. Any help is highly appreciated. Thanks.

NOTE: I have got the first part
I used PlistBuddy to set those values how I wanted them

/usr/libexec/PlistBuddy -c "Set com.apple.Safari.ContentPageGroupIdentifier.WebKit2JavaScriptEnabled true" ~/Library/Preferences/com.apple.Safari.plist

And so on for other values. But I still don't know how to access the one within a container the second part of the question. Please Help.


回答1:


I got both the answers.
I used PlistBuddy to change the values of the Plist

To change any Plist value I used

/usr/libexec/PlistBuddy -c "Set com.apple.Safari.ContentPageGroupIdentifier.WebKit2JavaScriptEnabled true" ~/Library/Preferences/com.apple.Safari.plist

To access the dict chain I used

/usr/libexec/PlistBuddy -c "Set ManagedPlugInPolicies:PlugInName:PlugInFirstVisitPolicy PlugInPolicyAllowNoSecurityRestrictions" ~/Library/Preferences/com.apple.Safari.plist

The last one was to allow a PlugIn named PlugInName to be always allowed.



来源:https://stackoverflow.com/questions/42645351/how-do-i-set-plist-values

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!