Skip to main content
 首页 » 编程设计

python之使用 Python 在 Mac 上设置文件夹背景图像

2025年05月04日8TianFang

我想根据名称更改 Mac OS 10.9 中文件夹的背景图像。我似乎无法找到任何改变 Python 背景图片的方法,也找不到关于背景图片的一般信息。

我相信背景图像和图标定位等内容存储在 .DS_Store 中,是否可以修改它以更改图像?

如果在 Python 中不可能,是否有推荐的语言可以做到这一点?

请您参考如下方法:

I believe things such as background image and icon positioning are stored in the .DS_Store, is it a possibility to modify this to change the image?

您可以使用 xattr 命令探索 DS_Store 设置,如果您使用的是默认 osx 实用程序,则可以使用 ls -@ 命令。

If it is not possible in Python is there a suggested language to be able to so this?

有 xattr允许您执行此操作的 python 包。

对于背景图片,我找到了that answer尽管它主要是关于 DMG。

不过,有一个 graphical recipe要实际更改文件夹的背景,我仍然找不到在那里使用的扩展属性……

我确实更改了文件夹的背景,但没有因此更改扩展属性设置。该文件夹也不包含 .DS_Store 文件。该信息可能存储在查找器使用的某些 Application Support 或 Preferences 数据库中......

最后,您可以使用以下信息轻松编写自己的 DS_Store 解析模块:

这告诉我们 DS_Store 确实有一个背景字段。

最后,看起来 perl 有一个 DS_Store 模块: