如何设置plist值 [英] How do I set plist values
问题描述
我正在尝试更改某些Safari设置,并尝试为此使用com.apple.Safari.plist.
这些是我需要更改的以下关键值
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
我尝试使用
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>
如何更改PlugInFirstVisitPolicy的值?我想将字符串更改为其他名称.
How do I change the value of PlugInFirstVisitPolicy? I want to change the string to something else.
有没有默认写入方式.我已经阅读了有关plistbuddy的信息,但不确定如何使用它.任何帮助都将受到高度赞赏.谢谢.
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.
注意:我已经掌握了第一部分
我用PlistBuddy设置了我想要的值
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.
推荐答案
我得到了两个答案.
我使用了PlistBuddy来更改Plist的值
I got both the answers.
I used PlistBuddy to change the values of the Plist
要更改我使用的任何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
要访问我使用的字典链
/usr/libexec/PlistBuddy -c "Set ManagedPlugInPolicies:PlugInName:PlugInFirstVisitPolicy PlugInPolicyAllowNoSecurityRestrictions" ~/Library/Preferences/com.apple.Safari.plist
最后一个是允许始终允许名为PlugInName的插件.
The last one was to allow a PlugIn named PlugInName to be always allowed.
这篇关于如何设置plist值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!