Category Archives: apple

Immediate macOS Screen Lock

[Danger: Unix nerd stuff ahead]

While I work from home sometimes, often times, I find myself working at customer locations, in airports, train stations, Starbucks, my company’s field offices, conferences, or in some sort of environment that’s less than fully trusted. When I find myself working in such places, if I walk away from my Mac even for a moment, I’m a good boy and lock my screen. It’s really a best practices from a security perspective, you should do it too.

I also recently got an Apple Watch. One of the features I really love is that if my watch is unlocked, and I open up my Mac, as long as I’ve already logged in and it’s just simply locked, I can unlock with my watch. Open the lid, be in range, bang, unlocked.  Love it.

I also seem to often times have a terminal window open for something. By the way, can’t say enough good about iTerm 2. Conventional wisdom recommends that CLI-savvy folks who want a quick way to lock your Mac should have a bash alias that looks something like:

alias afk="/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend"

If you’re an Alfred user, that’s the same thing Alfred’s doing behind the scenes if you use the “lock” command with Alfred configured with its defaults.  The problem with this? When you’re using non-local accounts, like accounts hosted in Active Directory, instead of getting the “just have your watch on, or type your password” sort of lock screen, you get something more like a login window where you must type your username & password to get back in.  Ok, so why not use a hot corner to activate the screensaver?

This is where my problem kick in.  Our IT team has lock set to kick in 1 minute after the screensaver activates, and I can’t change it to “immediately”. So, even if I use a hot corner, that doesn’t do the job.  I want the lock to be instantaneous.  macOS has a standard app for Keychain management called Keychain Access.app. It has a preference to show Keychain status in the menu bar. This menu has an option called “Lock Screen”, which does exactly what I want, but now I need to mouse around, click, click again, as opposed to a quick Alfred command or a bash alias to invoke the magic.

I found a discussion on Stackexchange about this very topic. Some kind soul wrote a few lines of Objective-C code that works perfectly. It actually calls the same feature the Keychain menu uses. Figuring I can’t be the only person who wants this, I tidied up the code a touch and put it on GitHub for posterity’s sake. Out of a desire to make it easy for others to install this, I even submitted a Homebrew Formula. Sadly, the code didn’t meet the requirements the guys who maintain homebrew-core wanted, but they suggested I make a tap instead.  A tap gives anyone the ability to install the software without having it in the main repository.  Want to install this and give it a go? Assuming you’ve already got Homebrew installed, you can just run these commands:

brew tap jcostom/taps
brew install maclock

If you would like to see maclock end up in homebrew-core, star the repo, and better yet, fork the project, improve, and send a pull request back!  I know enough Objective-C to fill a small post-it note. Maybe you know more?

Printing from the iPad without buying a new printer

Ok, so you’ve got a snazzy new iPad, and would like to print.  Since iOS 4.2, Apple has had AirPrint, which only works with a small set of HP printers.  While yes, it’s super cool to be able to print from the iPad, how much will you really do this?  If it’s enough to warrant buying a new printer, good for you.  If you’re like me, and want to have the ability to do so, but probably will rarely do it.  Read on to find out more. Continue reading Printing from the iPad without buying a new printer