Automatically lock screen if I leave the MacBook
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".
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.
- https://support.apple.com/en-us/HT206995
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.
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:
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
BLEUnlock
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.
Update
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.
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:
https://code.google.com/archive/p/reduxcomputing-proximity/
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.