I am using pykeylogger and want to extend it a little bit by adding information about current keyboard layout selected (right now you know from log what buttons are pressed assuming US qwerty).
For windows system it is looks like:
def get_locale(self):
if os.name == 'nt':
w = user32.GetForegroundWindow()
tid = user32.GetWindowThreadProcessId(w, 0)
return hex(user32.GetKeyboardLayout(tid))
to get hex code of layout (like 0x409409) that is fine for me as I basically want to distinguish one layout from another.
I would appreciate if you give me a solution for posix (for example ubuntu) system.
/etc/default/keyboard/sudo cat /etc/default/keyboardcommand returns same content for any current layout