Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get physical keyboard layout

Is there a way through command line to know what keyboard physical layout a macbook has? I cannot find that specific information in system_profiler. I want to know if the computer has a US, UK, ES, etc keyboard layout. The aim is to script it, upload it to my MDM so I can run it in all the company's laptops and find out that information.

Thanks!

running the terminal command system_profiler SPSPIDataType it shows this:

SPI:

Apple Internal Keyboard / Trackpad:

  Product ID: 0x0278
  Vendor ID: 0x05ac (Apple Inc.)
  ST Version: 8.96
  MT Version: 4.69
  Serial Number: FM7741701QVGN41A5+RNZ
  Manufacturer: Apple Inc.
  Location ID: 0x01000000

I run it in two different macbooks, one UK, one ES. I was hoping that the Location ID would show something different but that was not the case.

like image 387
Federico Joly Avatar asked Jan 19 '26 18:01

Federico Joly


2 Answers

If I do this in Terminal:

defaults read ~/Library/Preferences/com.apple.HIToolbox.plist AppleSelectedInputSources | egrep -w 'KeyboardLayout Name'

I get this:

"KeyboardLayout Name" = *name of my keyboard in readable form*
like image 200
jvarela Avatar answered Jan 22 '26 14:01

jvarela


I think I just found the solution, like this:

ioreg -l | grep KeyboardLanguage | awk '{print substr( $0, 56, 20)}' | tr -d "\" =|"

Thanks, Federico.

like image 32
Federico Joly Avatar answered Jan 22 '26 14:01

Federico Joly