My situation: I have a notebook with German keyboard layout running Ubuntu 16.04. It hosts an Android VM through QEmu/KVM, which is configured for German keyboard layout as well.

When I'm typing something in the VM using the real hardware keyboard, it works perfectly fine. However, as the guest system doesn't support a shared clipboard (or I am just too stupid to set it up), I wanted to use xclip and xdotool on the host to simulate typing the host's clipboard content into the VM.

The command I have bound to a keyboard shortcut is:

bash -c 'sleep 0.5 ; xdotool type --clearmodifiers "$(xsel -b)"'

This does its job and types whatever is in the host's clipboard buffer. Unfortunately, there seems to be some keyboard layout confusion when I use it to type something into my VM. For example, https://youtube.com becomes httpsÖ//zoutube.com in the VM.

To me this looks like xdotool is using the English QWERTZ keyboard layout to type, instead of the German layout I configured everywhere, as the German key Ö is used for `: in the English layout, and the keys Y and Z are swapped too (among other differences).

How can I teach xdotool or my VM or whatever component is responsible for the confusion to type using the correct keyboard layout?


It might not be the cleanest solution but this works for me.

Use setxkbmap before your xdotool command :

$ xdotool type azerty

$ setxkbmap fr && xdotool type azerty

I think it should also work if you put the layout in the .xinitrc

setxkbmap fr

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.