
OSX Hot Lock Screen Lock
Hello to you habrapuser!
Recently, I was faced with the need to lock the screen on a poppy. That I was able to google me was not satisfactory for various reasons, I just wanted to block the screen by hotkey. As it turned out, adding this opportunity itself does not present any difficulties, and only 10 minutes of time.
So, let's begin. To add a lock, we need only the built-in Automator system . You can easily find it through Spotlight

Our screen lock application will work as a system service. Why create a project "Service"

After which we need to add the actions of our program, we are interested in the “Run Shell Script” action. It just needs to be dragged onto the box on the right.

The script itself for locking the screen: You
/System/Library/CoreServices/"Menu Extras"/User.menu/Contents/Resources/CGSession -suspend
just need to copy it to the script input window, as shown below

Actually, our program is ready, now you can check its work by launching from Automator and if everything is fine, then save it as a service (cmd + s, then enter the name of our service, for example, “LockScreen”)
Open the system settings, go to the keyboard section, services and find our service.

We assign that hotkey that you like and that's it.