scripts icon indicating copy to clipboard operation
scripts copied to clipboard

LSAutoTimeZone.py Not triggering TimeZone lookup in 10.13.4b

Open ehemmete opened this issue 7 years ago • 3 comments

As is, the script errors on line 140 result = pref._startAutoTimeZoneDaemon_(0x1). The error is AttributeError: 'TimeZonePref' object has no attribute '_startAutoTimeZoneDaemon_'.

Changing that to result = pref.startService() allows the script to complete, but it then exits with Automatic Time Zone was not enabled or your machine doesn't support properly this functionality.

Location Services is enabled and Setting Time Zone is enabled in the Privacy panel, but the checkbox in Date & Time -> Time Zone is not checked the look up doesn't happen. Also due to exiting on the not enabled message means that NTP is not configured if un-commented. This was tested in 17E160g and 17E182a.

ehemmete avatar Mar 14 '18 19:03 ehemmete

I can confirm the above. The script worked for me up to 10.13.3 but not in 10.13.4 general release (17E199).

homebysix avatar Apr 06 '18 01:04 homebysix

Poking at this some more, it looks like the file for the "Set time zone automatically using current location" has changed. Using FSMonitor while changing the setting leads me to /private/var/db/timed/Library/Preferences/com.apple.timed.plist and TMAutomaticTimeZoneEnabled = 1; But changing that manually with defaults doesn't get reflected in the GUI. (killing cfprefsd doesn't seem to mater) I will continue poking, but wanted to share in case it sparks some other ideas.

Currently testing with: def autoset_timezone(): """Enable Set time zone automatically using current location""" auto_plist = '/private/var/db/timed/Library/Preferences/com.apple.timed.plist' cmd = ['/usr/bin/sudo', '-u', '_timed', '/usr/bin/defaults', 'write', auto_plist, 'TMAutomaticTimeZoneEnabled', '-int', '1'] subprocess.check_output(cmd)

ehemmete avatar May 02 '18 18:05 ehemmete

That value is actually a boolean however I was still unable to get 10.13.4 to respect any changes with regards to TimeZone preferences.

sudo -u _timed /usr/bin/defaults write /private/var/db/timed/Library/Preferences/com.apple.timed.plist TMAutomaticTimeZoneEnabled -bool FALSE

clburlison avatar May 21 '18 14:05 clburlison

Closing since Apple removed the ability to automate anything related to Location Services on macOS.

clburlison avatar Mar 26 '23 03:03 clburlison