I can use mouse clicks and keystrokes automation but I need the automation of changing timezone to be as fast as possible. Is apple script an answer? If yes, I can't write apple script.
What I am looking for?
The automation would be triggerd manually.
The automation would change my Mac's timezone to the specified timezone.
Great if I don't need to put in my password each time I have to change the timezone.
It appears to can set it using the command:
sudo /usr/sbin/systemsetup -settimezone "name"
You can list them with
-listtimezones and get with
The command must be run with administrator privs, but you could add the command to your sudoers file, which I think would be relatively safe if you fully supply the command.
The one that works is this (For london timezone):
echo 'your_password' | sudo -S systemsetup -settimezone Europe/London
Your code gave error. I put your code in chatgpt. And it corrected it. I tested and it works. [When you are typing the password, which is the password with which you have locked your laptop, do not put your password inside single inverted comma]
Assuming you'll be triggering the macro manually, you can prompt for the password and reference a variable in the script:
echo "$Local__Password" | sudo -S systemsetup -settimezone Europe/London
Your code gave error.
My code was copied verbatim from a Terminal window with the only change being the timezone name.
I strongly recommend against putting your admin password in clear text in a macro.
This is why I suggested a password prompt.
oh did you mention this in your last response?
I did not understand this line. I already have administrative priviledges (i.e. I am the admin). What are sudoers? How to fully supply command?
Why do you think it is not safe? I mean a person has to be physically able to access my laptop in order to use the password, right?
Indirectly, yes, I suggested putting it in the sudoers file which allows specific commands to be run with admin permissions without requiring a password.
That's for Ubuntu, but it covers the idea.
Any software running on your Mac could potentially access it (well, in theory, sandboxed software could not but in practice, who knows). Passwords should be at the least stored in the Keychain which you could do using the
Set Keychain Password to Text and Set Variable to Keychain Password actions and the technique @noisneil suggested.
But I prefer using sudoers because it removes having to store your password anywhere, and it's not much of a security risk to allow anything to change your timezone.