【问题标题】:Add boolean key to plist in Terminal将布尔键添加到终端中的 plist
【发布时间】:2012-07-19 03:07:48
【问题描述】:

我目前正在尝试创建一个终端 shell,它向现有 plist 添加一个名为“disabled”的布尔键,其值为真。

到目前为止我有defaults write "/System/Library/LaunchAgents/com.apple.AppStoreUpdateAgent" disabled -bool true

我是在正确设置布尔值,还是不应该有-bool? “禁用”应该用引号引起来吗?

【问题讨论】:

  • 这是一个根拥有的 plist 文件......所以希望你在修改默认值之前调用“sudo”......并且希望你知道你想要做什么。你到底想做什么?
  • 我正在禁用启动代理,当新用户登录 Mac 时会自动弹出,通知用户他们无权访问此启动代理(用于 Mac App Store 上的更新徽章)。我必须正常手动覆盖 plist,但我正在尝试使过程自动化一点。
  • 你看过the man page for defaults吗?

标签: macos bash shell unix terminal


【解决方案1】:

defaults write /System/Library/LaunchAgents/com.apple.AppStoreUpdateAgent disabled -bool true 应该是正确的。 disabled 不需要用引号括起来,-bool true 应该可以工作,但正如@MichaelDautermann 提到的,您需要以 root 身份运行它。

您也可以使用launchctl unload -w /System/Library/LaunchAgents/com.apple.AppStoreUpdateAgent.plist 卸载作业。

-w       Overrides the Disabled key and sets it to false. In previous ver-
         sions, this option would modify the configuration file. Now the
         state of the Disabled key is stored elsewhere on-disk.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多