Physical keyboard layout on macbooks

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.

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.


Solution 1:

I think I just found the solution, like this:

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