I want my MacBook to get locked automatically if I leave it.

I am open to ideas.

How could the MacBook detect this?

Switching off after one minute of inactivity is not enough. The screen most get locked sooner. And locking the screen after 20 seconds creates too many interrupts for the daily work.

I wear an Huawai GT2 Smartwatch. But that is just one idea.

Maybe I could install a physical sensor in my seat.

Any idea is welcome.

Background: I change the job and in the new company you need to pay pizza for the whole team if you forget to lock your screen :-)

I want it to be automated: I walk away and the screen should lock. No additional action should be required. Keyboard shortcuts, special mouse movements, unplugging devices from USB, bluetooth distance to mobile phone (I don't always carry around the phone) are not valid answers.

  • 2
    Change the background to a 'login window' image. – CousinCocaine Dec 13 '19 at 13:31
  • 1
    I laughed since that is something I’ve seen done and be effective. Same with a screensaver. @CousinCocaine – bmike Dec 14 '19 at 1:16
  • @Harv all suggestions were too complicated. I started the new job today and first I need to learn Mac. I used Ubuntu for the last 16 years. I will ask at the new job. Maybe someone has a simple (and automated) solution. – guettli Jan 2 '20 at 18:55
  • Well, I don't know how much more automated than installing and setting up an app it's going to get for you.. I know Ubuntu is about as easy as Linux gets but it can't be so simple that macOS seems complicated? Either way, I hope you find a solution that works for you. – Harv Jan 2 '20 at 23:23
  • 2
    crossposted on arduino.stackexchange.com/questions/71050/… – nohillside Jan 3 '20 at 10:33

We have the same culture in one of the environments in which I work. . . it's ruthless, so I know where you're coming from.

It's a good habit to get into to lock your screen whenever you leave it unattended, and soon you won't be on the hook for buying anymore pizza.

I find it helpful to set a "Hot Corner" for this.

Go to Preferences > Desktop & Screen Saver > Hot Corners

  • chose the corner of your liking, and set it to "Lock Screen"

I use the lower right, for example, and just sweep my mouse to that corner whenever I am about to stand up and walk away from my desk. Easy peasy!

You can also set the hot corner to "Start Screen Saver", but then you will need to set the following as well:

Also under Preferences > Desktop & Screen Saver

  • choose the screensaver of your liking, and set it to come in withing a comfortable amount of inactivity. (Realize, of course, that if you're reading something of length, and not moving the mouse of interacting with the keyboard, your screensaver may engage while you're reading/thinking/daydreaming.)

Go to Preferences > Security & Privacy

  • under the "General" tab, ensure that the option to require password "after sleep or screen saver begins" is selected. Set the timing option to "immediately".
  • 1
    Thank you for this hint with "hot corners". Still I think automation is heaven. I don't want to do boring repetitive work. – guettli Dec 5 '19 at 7:19
  • 1
    What about Command+Control+Q? I find this easier than having to watch when the pointer is hitting a certain corner. – Glen Yates Dec 9 '19 at 16:32
  • 1
    In my opinion this is not a valid answer to the question, because it does not "automatically lock [the] screen". – n1000 Dec 10 '19 at 11:12

The proximity unlock of Apple Watch is amazing on macOS so if you don’t get a great lock solution, at least you can set things to time out rapidly and be right back in with a press of the space bar or any other input.

Combined with hot corners to lock intentionally or other automation you should be set and secure and not inconvenienced when you are back in range of the Mac.

There are many App Store apps to lock on bluetooth leaving, but I’ve not seen them be reliable enough for me to trust - I lock my mac when I need to and have a short timeout of a couple minutes to reduce the exposure if I forget to lock.

Operating in closed clamshell mode, you might not be able to simply close the lid, but that’s a great solution for many that need to rapidly and clearly know their mac is locked if Command-Control-Q or a script launched by Siri isn’t easy enough.

  • 2
    Yeah, Command-Control-Q is the most reliable and safe method that I know. – Daniel Dec 13 '19 at 20:50

Keyboard Maestro can do this very easily… under certain circumstances.

For example, if I was in such an environment, I would use a macro like this:

enter image description here

And the “trigger” would be unplugging my iPhone from my MacBook… which obviously means that in order for this to work, you have to plug your iPhone into your MacBook when you are sitting at your desk.

I would never leave my iPhone on my desk, so this would be a completely effective way for me to make sure my MacBook was locked when I left my desk.

However, what I actually use at my desk is a Qi-charger, so I don’t have to plug/unplug it ever, and I would find using a USB connection annoying.

That being said, it would be less annoying that buying pizza for the entire office.

The problem with Bluetooth solutions is that all of them I have used are incredibly unreliable. Someone mentioned Knock which is hugely out-of-date, not to mention that it was meant to be used to unlock your Mac, not lock it.

(You can have your USB device name be whatever you want, and it would work if you have an Android device, etc.)

Instead of this…

What I would do instead of this is assign a keyboard shortcut such as command+control+option+L to run "/System/Library/CoreServices/Menu Extras/User.menu/Contents/Resources/CGSession" -suspend and just press that key combo when I stood up, but that’s not the automated solution you were asking for.

Bluetooth Apps


Unlox (formerly MacID)

are supposed to be able to tell when your iPhone moves away from your Mac. I haven’t tried these but older apps like these were unreliable. YMMV.


I tried Unlox and can report that it worked ok but it absolutely destroyed my battery life on my brand new iPhone 11 Pro Max. So… I would not recommend that route.

  • I have been thinking about locking via bluetooth, too. But if I walk ten meters to my colleagues desk, then I think it does not lock, since the device is still visible from the MacBook. – guettli Dec 5 '19 at 7:21
  • @guettli Pretty much any wireless setup is going to have the same problem. – Tom Harrington Dec 9 '19 at 18:36
  • Yup. The most reliable solution is the USB-based one. I’d find it annoying, but it would solve the problem. – TJ Luoma Dec 9 '19 at 18:54
  • @TJLuoma it solved the problem for you. Sorry for nitpicking, but is does not solve the issue for me. I want it to be automated. This means: I walk away and the screen should lock. No additional action should be required. – guettli Dec 10 '19 at 11:59
  • Oh I understand completely, and I even agree. I’m just saying that I don’t think there is a way to “automate” it any more reliably than the USB-method (which I understand is not “automated” in the sense that you want). Anything that uses Bluetooth is going to require a range that isn’t going to be feasible either. I think you’re in search of a solution that doesn’t exist -- but I would be very pleased to be wrong. (I’ve even tried thinking about ways to do it tied to weight on/off your office chair!) – TJ Luoma Dec 10 '19 at 21:00

Bluetooth proximity detection might work, there are apps in the iTunes store such as Knock which do this kind of thing using Bluetooth LE and iPhones...

For using a Huawai watch you might have to get more creative:


Unfortunately, I've never tried it and can't vouch for the code (or even if it works on most recent versions of MacOS). Maybe somebody here has experience with the tool or better tools.


Soma-Zone's RedHand is designed just for this. An excerpt from their website:

RedHand locks your computer. Manually via global hot key, menu bar or dock. Automatically after a period of inactivity (much like a screensaver), depending on the presence of a Bluetooth device, or whenever your computer goes to sleep.

I've used this software and I can attest that it was very effective, allowing a broad range of triggers to lock and wake up the Mac, including pairing with any Bluetooth capable device, and the ability to adjust the sensitivity (distance, effectively) of what could be considered a lock or unlock event.

In any case worth a look, and at $7CAD for a personal license, you can't go wrong if it works for you.

EDIT: while we're throwing out ideas, if your Mac has a touch-bar, I bought and set up BetterTouchTool and created an icon just next to my TouchID/power button that will lock my screen.

  • 1
    Do you use the Bluetooth proximity as a lock trigger? I found that with other apps, using that destroyed my iPhone’s battery life. Maybe it’s not an issue if you have a charger at your desk. – TJ Luoma Dec 13 '19 at 4:58
  • Yes, but you don't need to run an app on the phone to do it. What happens if that RedHand monitors the Bluetooth signal strength and you set its sensitivity. Once the strength is too low, the predetermined actions are triggered. Try it! – Harv Dec 13 '19 at 5:00
  • @Harv - If you have Touch bar, then you also have the built-in screen lock button - just add it 😎 – Rene Larsen Jan 3 '20 at 12:28
  • @ReneLarsen I use BTT and have a custom bar with a screen lock icon... I never use my touch bar honestly, could do without it. – Harv Jan 3 '20 at 21:52

You could use a distance sensor. See related answer to related question:

A single distance sensor, properly placed, should be enough to detect when you leave. That's the arduino part.

With python you can then use the serial over USB to read the output from the arduino. And run the command to activate the screen lock, according to your reading.

The arduino can get connected to the Mac via USB and pretend to be an usb keyboard. It can send the matching short-cut to close the mac.



  • 1
    How would this work with a Mac? – nohillside Jan 3 '20 at 10:32
  • @nohillside yes, you are right. The answer was missing a part: The arduino can get connected to the Mac via USB and pretend to be an usb keyboard. It can send the matching short-cut to close the mac. – guettli Jan 5 '20 at 10:36

I came to know about this application recently related to your question: https://nearlock.me

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .