There are various script incantations which yield strings like:
"com.apple.keylayout.British"
"com.apple.inputmethod.SCIM.ITABC"
"com.apple.keylayout.Hebrew-QWERTY"
"com.apple.keylayout.Greek"
etc.
For example:
(function () {
'use strict';
ObjC.import('Carbon');
ObjC.bindFunction('CFMakeCollectable', ['id', ['void *']]);
return $.CFMakeCollectable(
$.TISGetInputSourceProperty(
$.TISCopyCurrentKeyboardInputSource(),
$.kTISPropertyInputSourceID
)
)
.js
})();