Lock and Unlock Mac from iPhone
A few weeks ago, I was considering entering the Dartmouth hackathon, but decided not to because I woke up too late to give someone else a chance to win. However, when browsing around the Devpost site, I found a project called ezTouch. It caught my eye, as it allowed you to lock and unlock your computer from anywhere using your iPhone. Unfortunately, there was no GitHub repo, and the url that was linked in the Devpost article was no longer active. So I wondered how easy it would be to do!
As a quick disclaimer, in the end I decided not to pursue my solution due to a variety of reasons, so if you're looking for someone who was going to give you a GitHub link, keep looking! This post will serve more for some of the architecture decisions that I went through, and why it's always worth spending 5 minutes at the beginning of implementing an idea to really think through it.
The first thing that I did was a quick GitHub search, but only found a boilerplate repo with no actual code. Okay, so I couldn't find anything from the project online. And I couldn't find any related projects, so I decided to dive in. I found this StackOverflow post (with a surprisingly small amount of views/interest) explaining how to lock and unlock remotely over SSH. I figured if there was an easy way to SSH in, then it would be easy to do this. However, I didn't want to start a constantly running service to create a server, and because the IP would change for the computer, I looked for finding an IP for a computer.
I found something called 'Back to My Mac' which will enable a URL login through your iCloud account, but it only works from Mac to Mac, and thus wouldn't work in this case. So I scrapped that, and looked into CloudKit and CloudKit JS. I didn't really want to set up servers still, and I figured I could make an iOS app and Mac app that could use the iCloud data. In fact, I knew that there were push notifications to apps from CloudKit databases, so it could all be handled by Apple! However, I quickly found out that there's no way to easily listen from the Mac client, and the issues started to pile up.
I was working on it in a room with some friends, and someone asked what I was doing. I explained the project, and he said "Why though? Would you ever use this?" I thought, and honestly replied "Probably not". Why was I doing this if I had no desire to use it? I rationalized that maybe other people would use it. But now I was a little more skeptical, and did some more digging. The new Macs have fingerprint readers, and there are countless solutions for unlocking your Mac with your phone via Bluetooth, with no personal action. In what world would I rather press a button, or would need to lock/unlock my Mac while not within Bluetooth range? Without a strong use case, I finally managed to pull myself away from the project. Even still, I wanted to get it into a place where someone could use it, because I'd put in a few hours. Luckily, I managed to drop it, minus the additional work of writing this up in a blog post so that sometime in the future when I think about solving a problem that no one has, not even me, I'll just put it to the side.