Skip to content

Instantly share code, notes, and snippets.

@mosen
Forked from pudquick/autotimezone.py
Last active November 9, 2016 23:14
Show Gist options
  • Save mosen/a2350113ad3a29800ee312b03c258ea9 to your computer and use it in GitHub Desktop.
Save mosen/a2350113ad3a29800ee312b03c258ea9 to your computer and use it in GitHub Desktop.
Forcing automatic timezone discovery with pyobjc on OS X
# Tested on 10.11
# Assumes your network is in a state to actually do the discovery and that you have
# automatic timezone discovery enabled in Date & Time and Location services enabled
# (Generally this means wifi enabled on your device and network stack is up)
# For enabling location services and auto, check Allister's work here:
# https://gist.github.com/arubdesu/b72585771a9f606ad800
#import <Foundation>
NSBundle *TZPP = [NSBundle bundleWithPath:@"/System/Library/PreferencePanes/DateAndTime.prefPane/Contents/Resources/TimeZone.prefPane"];
TimeZonePref = [TZPP classNamed:@"TimeZonePref"];
ATZAdminPrefererences = [TZPP classNamed:@"ATZAdminPrefererences"];
atzap = [ATZAdminPrefererences defaultPreferences];
pref = [[TimeZonePref] alloc] init];
[atzap addObserver:pref forKeyPath:"enabled" options: 0 context: 0];
result = pref._startAutoTimeZoneDaemon_(0x1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment