我正在编写一个 bash 脚本,负责在我的 mac 上设置桌面背景。我可以设置桌面背景:
$ osascript -e 'tell app "Finder" to set desktop picture to POSIX file "/Library/Desktop Pictures/Solid Colors/Solid White.png"'
但是,我还需要获取桌面图片的路径。我得到的最接近的是:
$ osascript -e 'tell app "Finder" to get desktop picture'
这将返回桌面图片的路径,但格式非常奇怪,我无法使用:
document file Solid White.png of folder Solid Colors of folder Desktop Pictures of folder Library of startup disk
有什么办法可以得到当前桌面图片的路径,返回:
/Library/Desktop\ Pictures/Solid\ Colors/Solid\ White.png
?
最佳答案
像这样:
osascript -e '
tell application "Finder"
set theDesktopPic to desktop picture as alias
set theName to posix path of theDesktopPic
end tell'
/Users/mark/Documents/Carbon fibre.png
关于macos - Mac : Getting path of current desktop picture from terminal,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28783834/