Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fix macOS global "Country" setting
# view gloabl prefs in json
# plutil -convert json -o - -- /Library/Preferences/.GlobalPreferences.plist | python -m json.tool
import CoreFoundation as cf
# get current Country
cf.CFPreferencesCopyValue('Country', cf.kCFPreferencesAnyApplication, cf.kCFPreferencesAnyUser, cf.kCFPreferencesAnyHost)
# set Country
cf.CFPreferencesSetValue('Country', 'TW', cf.kCFPreferencesAnyApplication, cf.kCFPreferencesAnyUser, cf.kCFPreferencesAnyHost)
# persist changes
cf.CFPreferencesSynchronize(cf.kCFPreferencesAnyApplication, cf.kCFPreferencesAnyUser, cf.kCFPreferencesAnyHost)
# it's a lot easier to use 'defaults' to change the global .plist
#
# credit: @ShallJaiden in comments
#
sudo defaults write /Library/Preferences/.GlobalPreferences.plist Country -string "TW"
@Eric-Guo

This comment has been minimized.

Copy link

@Eric-Guo Eric-Guo commented Jul 16, 2020

Need brew unlink python first if install the brew version before

@ushuz

This comment has been minimized.

Copy link
Owner Author

@ushuz ushuz commented Jul 16, 2020

Need brew unlink python first if install the brew version before

Or, you can always use /usr/bin/python

@ShallJaiden

This comment has been minimized.

Copy link

@ShallJaiden ShallJaiden commented Sep 13, 2021

this doesn't work for me. I just simply run sudo defaults write /Library/Preferences/.GlobalPreferences.plist Country -string "TW"
that works for me

@ushuz

This comment has been minimized.

Copy link
Owner Author

@ushuz ushuz commented Sep 13, 2021

this doesn't work for me. I just simply run sudo defaults write /Library/Preferences/.GlobalPreferences.plist Country -string "TW"
that works for me

Thanks for sharing, that's far better. I'll incorporate it into the script for future visitors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment