Home > Apple > Mac

Switch between different times until Lock Screen is activated [Mac]

In this guide, we will show you a couple of methods to switch between different times until the lock screen is activated on your Mac. To get this job done, we will be showing you three different methods- from Terminal, by creating a command file, and via an app created by Apple Script. The Terminal method is the easiest to carry out whereas the lengthiest one.

When it comes to the command file, it is created via TextEdit, so your password will be there in plain text format. It’s not an issue if this is your PC but in case you’re on a shared PC, then it could prove to be a risky bet. With that said, you are aware of the benefits and the potential. risk of these methods, so try out the one which is in sync with your requirements.

How to switch between different times until Lock Screen is activated on Mac

Switch between different times until Lock Screen is activated

Using Terminal

  1. The below command will make the action get executed “immediately” [make sure to replace AdminPassword accordingly].
    sudo sysadminctl -screenLock immediate -password AdminPassword
  2. Or if you want it for 3 minutes, then use the below command. Time is being shown here in seconds, so 3 minutes corresponds to 180 seconds
    sudo sysadminctl -screenLock 180 -password AdminPassword

Using Command File

Create a new TextEdit file, input the below command, and save it as a .command file. Moreover, the below command takes the password as 123, sets the lock screen to 3 minutes, and then opens the Calendar app. So make sure to change these values accordingly, if needed.

#!/bin/zsh
sudo sysadminctl -screenLock 180 -password 123
open -a /System/Applications/Calendar.app

Via App [Create with Apple Script]

In the below code, the username is Admin and the password is 123. Make sure to replace them accordingly.

set question to display dialog "The screen lock is set to: " & ScreenLockStatus & return & "Would you like to:" buttons {"Set to immediate", "Set to 5 minutes", "Cancel"} default button 1
set answer to button returned of question
if answer is equal to "Set to immediate" then
do shell script "sudo sysadminctl -screenLock immediate -password 1234" user name "Admin" password "123" with administrator privileges
end if
if answer is equal to "Set to 5 minutes" then
do shell script "sudo sysadminctl -screenLock 300 -password 1234" user name "Admin" password "123" with administrator privileges
end if
if answer is equal to "Cancel" then
return
end if

That’s it. These were the three different methods to switch between different times until the lock screen is activated on your Mac. If you have any queries concerning the aforementioned steps, do let us know in the comments. We will get back to you with a solution at the earliest.


Share: