How to know what keyboard layout is being used

I’d like to find out what the current keyboard layout (“input locale”) is, for the current user/Platform (in a cross-platform way, if possible). I’ve come up with this (awkward) way to do it via unixCmd on Windows – maybe there is a nicer way to do it.

var inputLocale =
	\windows, {
		var lines = "systeminfo /fo csv".unixCmdGetStdOutLines[(0..1)];
		var sysInfo = lines.collect(_.replace("\",\"", "|")).collect(_.split($|)).flop;
		sysInfo.detect{|x| x.first.beginsWith("Input Locale") }.last
	\linux, { /* TBD */ nil },
	\osx, { /* TBD */ nil }

// -> "es;Spanish (Traditional Sort)"


P.S. On macOS, it seems you’d have to do something like this. Here’s hoping there is a built-in way of doing it – perhaps some cross-platform Qt method?

1 Like

The Qt layer/lib definitely has access to this info (you can even be notified on changes, e.g. if user hits Alt-Shift in Windows), but I’m not sure it’s exposed in SC’s Qt bindings. (There’s lots of other Qt stuff that isn’t.)