Posted on 05-31-2023 05:06 AM
Does anyone know if it is possible to collect (e.g. via Extension Attribute) the physical Keyboard Layout of a Macbook and the color of the Macbook (Space Gray / Silver / whatever)?
Posted on 05-31-2023 10:47 AM
Interesting question.... If you enter system_profiler SPBluetoothDataType into Terminal, it outputs all of the Bluetooth connected devices. Here's a portion of what that outputs for me on my Mac mini. What I didn't see was something identifying what color my keyboard is. I thought maybe the product ID would be unique to the Space Gray Apple keyboard with Touch ID, but it doesn't appear to be. If there is any info in this output that identifies the keyboard specifically as either Space Gray or Silver you would need to start with SPBluetoothDataType and then grep what ever part of the output identifies the keyboard color. I don't think this information is collected though.
Bluetooth Controller:
Address: 20:A5:CB:CC:39:DF
State: On
Chipset: BCM_4388
Discoverable: Off
Firmware Version: 20.6.285.1824
Product ID: 0x4A15
Supported services: 0x382039 < HFP AVRCP A2DP HID Braille AACP GATT SerialPort >
Transport: PCIe
Vendor ID: 0x004C (Apple)
Connected:
Howie’s Magic Keyboard:
Address: 08:95:42:EE:0E:2D
Vendor ID: 0x004C
Product ID: 0x029F
Firmware Version: 1.4.8
Minor Type: Keyboard
Services: 0x800020 < HID ACL >
Howie’s Magic Trackpad:
Address: BC:D0:74:BA:06:38
Vendor ID: 0x004C
Product ID: 0x0265
Firmware Version: 1.9.2
Minor Type: AppleTrackpad
Services: 0x800020 < HID ACL >
Posted on 05-31-2023 12:43 PM
Hi, see if this fits your needs for the keyboard layout EA.
#!/bin/bash
KEYBOARD_LAYOUT=$(defaults read /Library/Preferences/com.apple.HIToolbox.plist AppleEnabledInputSources | grep "KeyboardLayout Name" | awk '{printf "%s ", $4}'| sed 's/;.$//' | tr -d '"')
echo "<result>$KEYBOARD_LAYOUT</result>"
exit 0
Posted on 06-05-2023 05:01 AM
Someone had the same question about gathering the mac color a few months ago in the post below. It is possible, but not really worth the effort. You need to identify every Model Number in your environment, and make the EA with if statements to connect a certain Model Number to a color. This would need to be updated every time you get a new model number.
Solved: Set name from iMac M1 based on color - Jamf Nation Community - 288210
An example script, it would need every Model Number in your environment added. The Model Numbers are color specific, but change with custom SKUs.
#!/usr/bin/env bash
serialNumber=$(system_profiler SPHardwareDataType | awk '/Serial/ {print $4}')
modelNumber=$(system_profiler SPSoftwareDataType SPHardwareDataType | awk '/Model Number/ {print $3}')
if [ "Z12U000SEFN/A" == "$modelNumber" ]
then
echo "Someone got a pink iMac"
scutil --set ComputerName "pink $serialNumber"
else
echo "thank god its not pink"
fi
if [ "MK193LL/A" == "$modelNumber" ]
then
echo "Good, someone has the only correct color; space gray"
scutil --set ComputerName "Space Gray $serialNumber"
else
echo "Its not space gray?!?! What is wrong with this person"
fi