iMac, Target Display Mode and no keyboard

Older iMacs can be used as external displays for other Macs. Target Display Mode works seamless, but if you want to turn your iMac off after a day of work and keep your other Mac on, you’ll need to click CMD+F2 to switch again or unplug/plug the cable on the next day.

I took a few minutes and I wrote a code in C++ that did the CMD+F2. It worked for a while. Then, I figured that “while” was while my Apple Keyboard was connected to the iMac.

Luckily, I found a blog post on the internet about reverse engineering the thing, so it explains how Apple does to switch display modes (Source: https://floe.butterbrot.org/matrix/hacking/tdm/). Finally, my job was to find a way to write bytes to SMC.

It was mentioned that SMCKit (https://beltex.github.io/SMCKit/) was used to tests, so I cloned the repo and installed on my computer. The CLI is focused on temperature, but the kit had what I needed, so I wrote another option to the CLI to write the bytes where I needed. And boom! It worked!

Lastly, I don’t want to keep any input device plugged in my iMac, so I created a plist and added to LaunchAgents saying that it should be run in “LoginWindow”. I restarted my iMac and TDM was set automatically. Now, I have a “Cinema Display” running on my MacBook Pro.

Published by

Leave a Reply