Created
September 5, 2018 09:45
-
-
Save ruzz311/4f8ca85f9cb5f54225cceacbce6bf4b0 to your computer and use it in GitHub Desktop.
An applescript to toggle timezone between current location and GMT. Exporting as a "readonly app" will prevent others from seeing your password
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
property myUser : "user-name" | |
property myPass : "password" | |
property defaultTimeZone : "America/Los_Angeles" | |
on doSudoShellScript(myScript) | |
return do shell script myScript user name myUser password myPass with administrator privileges | |
end doSudoShellScript | |
on getTimeZone() | |
return doSudoShellScript("/usr/sbin/systemsetup -gettimezone") | |
end getTimeZone | |
on setTimeZone(timezone) | |
return doSudoShellScript("/usr/sbin/systemsetup -settimezone " & timezone) | |
end setTimeZone | |
-- val is on|off | |
on setUseNetworkTime(val) | |
return doSudoShellScript("/usr/sbin/systemsetup -setusingnetworktime " & val) | |
end setUseNetworkTime | |
-- val is true|false | |
on setAutoTimeZone(val) | |
return doSudoShellScript("/usr/bin/defaults write /Library/Preferences/com.apple.timezone.auto Active -bool " & val) | |
end setAutoTimeZone | |
if (((getTimeZone()) as string) = "Time Zone: GMT") then | |
setUseNetworkTime("on") | |
setTimeZone("America/Chicago") | |
setAutoTimeZone("true") | |
display notification with title "TimeZone Changed" subtitle defaultTimeZone | |
else | |
setUseNetworkTime("off") | |
setTimeZone("GMT") | |
setAutoTimeZone("false") | |
display notification with title "TimeZone Changed" subtitle "GMT" | |
end if | |
delay 1 --> allow time for the notification to trigger |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment