Skip to content

Instantly share code, notes, and snippets.

@tfausak
Created March 14, 2011 16:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tfausak/869386 to your computer and use it in GitHub Desktop.
Save tfausak/869386 to your computer and use it in GitHub Desktop.
Zeros out (doesn't delete!) the current randomly-selected background in OS X.
#!/usr/bin/env python
from BeautifulSoup import BeautifulStoneSoup
from commands import getoutput
from os.path import expanduser, join
plist = '~/Library/Preferences/com.apple.desktop.plist'
xml = getoutput('plutil -convert xml1 -o - -- {0}'.format(plist))
soup = BeautifulStoneSoup(xml)
file_name = folder_name = ''
for tag in soup.findAll('key'):
if tag.string == 'LastName':
file_name = tag.nextSibling.nextSibling.string
elif tag.string == 'NewChangePath':
folder_name = tag.nextSibling.nextSibling.string
path = join(expanduser(folder_name), file_name)
print 'Delete {0}?'.format(path)
input = raw_input('[y/N] '.format(path))
if input == 'y':
open(path, 'w')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment