Skip to content

Instantly share code, notes, and snippets.

@Tonyliu2ca
Forked from gregneagle/gist:6225747
Created October 31, 2013 04:58
Show Gist options
  • Save Tonyliu2ca/7244569 to your computer and use it in GitHub Desktop.
Save Tonyliu2ca/7244569 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import os
import subprocess
import sqlite3
desktop_picture_path = '/Library/Desktop Pictures/Wave.jpg'
database_location = os.path.expanduser(
'~/Library/Application Support/Dock/desktoppicture.db')
conn = sqlite3.connect(database_location)
print 'Opened database successfully'
conn.execute('DELETE FROM data')
conn.execute('INSERT INTO data VALUES (?)', (desktop_picture_path, ))
conn.execute('VACUUM data')
conn.commit()
print 'Records created successfully'
conn.close()
subprocess.check_call(['/usr/bin/killall', 'Dock'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment