Detecting a Touchbar Mac

Today’s task, figure out if the machine has a touch bar or not.

While there’s a few files that contains info about the touch bar:

"~/Library/Preferences/com.apple.controlstrip.plist"
"~/Library/Preferences/com.apple.touchbar.agent.plist"

These are user files. Which is fine to pull on, but better yet would be pulling on a file that doesn’t require Casper Jamf Pro to know about the user.

Emily had a great suggestion of using the following:

"/System/Library/PreferencePanes/TouchID.prefPane"

With a working demo:

This way would also work. However, what if Apple releases a TouchID mac without a touch bar? I’d have to go and re-work my script.
Further digging, and reading a blog post from Erik lead me down the road of what about reading the process.

Modifying Emily’s original script I then came up with:

While this works you could also further define it by using the TouchBarAgent (again pointed out to me by Emily)

My Final result was this:

Thanks to Emily for talking me through this.

 

Update 1 –  12-15-16:

I didn’t mention the other option, defining touch bar by model #. While technically this is the most accurate way todo it. By scripting MacBookPro13,2 and MacBookPro13,3 or the 15 alike. This wouldn’t stand the intended test of time that I was aiming for. With every new revision of the MacBook pro I’d then have to add that to my scripts.

Update 2 – 12-16-16:

Emily pointed something out, if you run Touché it activates both ControlStrip and TouchBarAgent.

Update 3 – 12-16-16:

After further poking and trying to minimize edge cases, searching the ioreg for AppleEmbeddedOSSupportHost works better. As machines that do not have touch bars do not have this value.