Skip to content

Instantly share code, notes, and snippets.

@mosen
Last active June 5, 2017 14:37
Show Gist options
  • Save mosen/f28bcd4552cc6805c7c4b3970d2b99ef to your computer and use it in GitHub Desktop.
Save mosen/f28bcd4552cc6805c7c4b3970d2b99ef to your computer and use it in GitHub Desktop.
#!/usr/bin/python
from CoreFoundation import CFPreferencesCopyValue, CFPreferencesSetValue, kCFPreferencesCurrentUser, \
kCFPreferencesAnyHost, CFPreferencesSynchronize
# Reading a preferences value
v = CFPreferencesCopyValue('NSNavLastRootDirectory', 'com.apple.Finder', kCFPreferencesCurrentUser, kCFPreferencesAnyHost)
print(v)
# Writing a preferences value
CFPreferencesSetValue('FXConnectToLastURL', 'smb://somewhere', 'com.apple.Finder', kCFPreferencesCurrentUser, kCFPreferencesAnyHost)
# Required to force preferences to sync to .plist on disk
CFPreferencesSynchronize('com.apple.Finder', kCFPreferencesCurrentUser, kCFPreferencesAnyHost)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment