Created
March 14, 2011 16:10
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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