我正在尝试向我的 OS X 配置脚本添加一个命令,该命令将背景设置为纯深灰色,但是,当应用时,它只会将其设置为主显示器,并且当前连接的任何其他显示器都会保留其当前背景,此后添加的任何显示器仍会接收默认的空间背景。到目前为止,我的情况如下:
# 将桌面默认背景颜色改为灰色
defaults write com.apple.desktop '{ Background = { default = {BackgroundColor = ( "0.25490197
如何通过终端命令将默认背景设置为深灰色?如何通过终端命令将所有已配置的显示器更改为灰色?
答案1
以下是您可以使用的 Applescript 命令
set localLibrary to path to library folder from local domain as string
set desktopImage to localLibrary & "Desktop Pictures:Solid Colors:Solid Gray Dark.png" as alias
tell application "Finder" set desktop picture to desktopImage end tell
您可以轻松地将上述任何 Applescript 转换为终端命令osascript [-e statement]
:
osascript -e 'set desktopImage to POSIX file "/Library/Desktop Pictures/Solid Colors/Solid Gray Light.png"tell application "Finder"
set desktop picture to desktopImage
end tell'
答案2
您可以使用 macOS Monterey 12.4 上的命令osascript
设置每个桌面上的图片,例如:
osascript -e "tell application \"System Events\" to tell every desktop to set picture to \"/System/Library/Desktop Pictures/Solid Colors/Stone.png\" as POSIX file"
要查找 macOS Monterey 的预装桌面图片:
find '/System/Library/Desktop Pictures' -not -path '*/.*'
要查找 macOS Big Sur 的预装桌面图片:
find '/Library/Desktop Pictures' -not -path '*/.*'
如果您希望制作一个更易于阅读的脚本:
file="/System/Library/Desktop Pictures/Solid Colors/Stone.png"
osascript -e "tell application \"System Events\" to tell every desktop to set picture to \"${file}\" as POSIX file"