Python スクリプトを実行して画像をダウンロードし、1 つのスクリプトでデスクトップの背景を変更しようとしています。うまくいけば画像部分をダウンロードしますが、実際にPythonで壁紙を変更するのに問題があります。このコマンドを使用しようとしていますが、実際には機能しません。以下は私の試みです
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)