【问题标题】:Modifying the "Spaces" plist on OSX to set default desktops修改 OSX 上的“Spaces”plist 以设置默认桌面
【发布时间】:2012-03-14 07:47:53
【问题描述】:

我目前正在尝试通过修改 10.6(和 10.7)上与“Spaces”关联的 plist 来将应用程序默认设置为所有桌面。在 Snow Leopard 上,可以通过转到 System Preferences > Expose and Spaces 来设置应用程序的默认桌面,并将应用程序设置为默认显示在所有空间上。这按预期工作,我的应用程序出现在所有桌面上。

但是,我正在寻找一种实用的方法,并且希望能够在我的应用程序中设置此功能。我找到了与每个操作系统相关的 plist 文件:

OS X 10.7: ~/Library/Preferences/com.apple.spaces.plist

OS X 10.6: ~/Library/Preferences/com.apple.dock.plist

编辑这些文件(参考应用程序桌面默认设置),然后使用 killall Dock 重新启动扩展坞不会影响我的应用程序在 Spaces 中的显示位置。

我也尝试过使用 defaults 来设置我的默认桌面:

defaults write com.apple.dock workspaces-app-bindings -dict-add com.mybundle.thing  65544

这也不起作用,因为应用程序没有与正确的桌面(或所有桌面,如上述命令所示)关联。

这两种方法都会使应用程序显示在“系统偏好设置”面板中,并显示正确的空间分配。但是,除非我直接从系统偏好设置中分配它,否则它无法正常工作。

除了 plist 之外,我还需要设置什么其他东西才能让它工作吗?

【问题讨论】:

    标签: macos osx-lion plist osx-snow-leopard


    【解决方案1】:

    10.7 似乎将“所有空格”存储为字符串 AllSpaces

    作为参考,它使用空字符串将应用程序绑定到主桌面,并根据空间的 uuid 值绑定到其他空间。

    【讨论】:

    • 有没有人在 10.8 中以编程方式执行此操作,并且让系统实际执行您的更改,而无需通过单击停靠图标来更改和重新设置首选项?
    【解决方案2】:

    这个 Applescript 在 OSX 10.8.5 中为我工作了一个类似的项目, 但它只列出了每个空间的名称,(我有 9 个空间。)这是访问 plist 数据的简单方法。我确信可以对其进行调整以重写 plist。

    tell application "Finder" to set propsLST to alias ((home as text) & ¬
    "Library:Preferences:com.apple.spaces.plist") as text
    
    tell application "System Events" to set theSPACES to value of every property list item of property list item "Space Properties" of property list item ¬
     "SpacesConfiguration" of contents of property list file propsLST
    
    set spacesLST to {}
    
    repeat with eachSPACE in every item of theSPACES
      set {spaceNAM, spaceWNDW} to eachSPACE as list
      set end of spacesLST to spaceNAM
    end repeat
    
    return spacesLST
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-04-24
      • 2012-11-24
      • 1970-01-01
      • 1970-01-01
      • 2011-04-09
      • 1970-01-01
      • 2012-12-14
      相关资源
      最近更新 更多