Set OS X Wallpaper via SQLite

None of theĀ other solutions work on Mavericks anymore because Apple moved the settings to a sqlite DB. But that’s ok because now it’s easier, the png can be anywhere in the filesystem, and all desktops (even virtual) are updated.

 #!/usr/bin/env bash
 sqlite3 ~/Library/Application\ Support/Dock/desktoppicture.db "update data set value = '/path/to/any/picture.png'";
 killall Dock;

Or, add it as a function to your ~/.bash_profile and call it as a terminal command with any non-relative path.

#   Update all Wallpapers
function wallpaper() {
    sqlite3 ~/Library/Application\ Support/Dock/desktoppicture.db "update data set value = '$1'" && killall Dock
}
wallpaper ~/path/to/any/picture.png

or AppleScript

osascript -e 'tell application "Finder" to set desktop picture to POSIX file "/path/to/picture.jpg"'