我正在尝试运行python脚本来下载图像并通过一个脚本更改桌面背景。下载图像部分如果没问题,但我实际上在用python更改壁纸时遇到了麻烦。我正在尝试使用this command但它实际上并不起作用。以下是我的尝试
subprocess.call(["defaults", "write", "com.apple.Desktop", "background", 'default=/Users/pathtomyname/img.jpg'])
SCRIPT = """/usr/bin/osascript<<END
tell application "Finder"
set desktop picture to POSIX file "%s"
end tell
END"""
def set_desktop_background(filename):
subprocess.Popen(SCRIPT%filename, shell=True)