I have finally had enough of Mavericks’ shenanigans when it comes to Desktop Wallpapers…
For those not in the know, in OS X Mavericks, Apple has changed the mechanism for configuring Desktop Wallpaper from the venerable .plist to using a Sqlite3 database.
While using the database is probably more robust and easier to integrate, it is not as easy to change the desktop or, even more important from my perspective, to change all your desktops to the same wallpaper.
After some Googling and digging, I finally came up with the following little Python script which I called, reasonably enough,
#!/usr/bin/python from __future__ import print_function import os, sys, subprocess import sqlite3 if len( sys.argv ) < 2: sys.exit( 'Usage: "%s" file-name' % sys.argv[ 0 ] ) if not os.path.exists( sys.argv ): sys.exit( 'ERROR: File "%s" was not found!' % sys.argv[ 1 ] ) desktop_picture_path = sys.argv[ 1 ] database_location = os.path.expanduser( '~/Library/Application Support/Dock/desktoppicture.db' ) conn = sqlite3.connect( database_location ) print( 'Opened database', end=", " ) cur = conn.cursor() cur.execute( 'SELECT count( DISTINCT display_id ) + 1 FROM pictures;' ) displays = cur.fetchone() cur.execute( 'SELECT count( DISTINCT space_id ) + 1 FROM pictures;' ) spaces = cur.fetchone() conn.execute( 'DELETE FROM preferences' ) conn.execute( 'DELETE FROM data' ) conn.execute( 'INSERT INTO data VALUES (?)', ( desktop_picture_path, )) conn.execute( 'VACUUM data' ) screens = spaces * displays for screen in range( screens ): conn.execute( 'INSERT INTO preferences VALUES (1,1,?)', ( screen + 1, )) conn.execute( 'VACUUM preferences' ) conn.commit() print( 'Records created successfully', end=", " ) conn.close() print( 'Closed database' ) subprocess.check_call( ['/usr/bin/killall', 'Dock'] )
Not all that impressive, I’m fully aware, but it does seem to do the job. Using it is simplicity itself:
As usual, do with it what you will…