【问题标题】:Applescript : Remove specific items from plist dock using the provided persistent apps arrayApplescript:使用提供的持久应用程序数组从 plist 扩展坞中删除特定项目
【发布时间】:2021-11-06 08:44:10
【问题描述】:

您好,我正在尝试使用脚本从默认扩展坞中删除和添加几个特定应用程序。

tell application "System Events"
    tell property list file "~/Library/Preferences/com.apple.dock.plist"
        set value of property list item "Firefox.app" to null
    end tell
end tell

这就是我所拥有的,它会引发错误

error "System Events got an error: Can’t set property list item \"Firefox.app\" of property list file \"/Users/immam.m/Library/Preferences/com.apple.dock.plist\" to null." number -10006 from property list item "Firefox.app" of property list file "/Users/immam.m/Library/Preferences/com.apple.dock.plist" to null

我还想找到一种将应用程序添加到阵列的方法,以便它在 KIllall 命令时显示在 Dock 上。

很抱歉,如果这是一个简单的过程,对于 mac 和 applescript 来说还是很新的。 感谢您的帮助

【问题讨论】:

标签: arrays macos applescript plist dock


【解决方案1】:

我用不同的方法弄明白了

do shell script "
    
    defaults write com.apple.dock persistent-apps -array 
    
    
    '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>System/Applications/System Preferences.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>'  

.. keep adding to the array

;
Killall Dock;"

【讨论】:

    猜你喜欢
    • 2012-01-09
    • 2012-02-21
    • 1970-01-01
    • 2012-07-30
    • 2020-07-03
    • 2017-06-20
    • 2014-11-14
    • 2020-02-04
    相关资源
    最近更新 更多