Ubuntu – Keyboard layout issues using Ubuntu 12.04 in ssh via X11 for mac

12.04keyboard-layoutmacosxx11

I just upgraded from 10.04 LTS to 12.04 LTS on my server (DELL Intel XEON). By SSH login from my mac (OS X Lion) everything is fine (no issues with command lines) but when I open a window through X11, the keyboard layout is now completely messed up. As an owner of a french mac keyboard, I got used to such issues and could deal by guessing the "QUERTY" keys, but this time it's worse.

To fix it, I tried:

1/

sudo dpkg-reconfigure keyboard-configuration

=> no effect

2/

sudo gnome-control-center

then change the keyboard settings, however adding a couple of keyboard layouts did not change anything.

I feel there is something to do with the X11 forwarding.
Any hints?

Thanks

Best Answer

In my case, running Yosemite and the latest version of xquartz, going through ssh -X to CentOS 6.5 in VMWare Fusion, I could not resolve that problem with switching layouts. US and Russian layouts, in my case. When I started, for example, gnome-terminal, I just couldn't switch to my RU language, using any key combinations. So, after half a day of experimenting (I am not really a Linux geek, just kinda "half-of-a-power" user), I found a solution.

Your mac ~/.profile should look like this:

export LC_COLLATE=en_US.UTF-8
export LC_ALL=ru_RU.UTF-8

If you use another language, change LC_ALL= for your language in your MacOs.

Then you need to add the following line at the end of your ~/.bash_profile on your ssh-connected machine (in my case - CentOS 6.5)

setxkbmap -rules evdev -model pc104 -layout us,ru

This goes correctly, especially for the Russian language. But I am sure your OS must have another collection of layouts. And, at the end - ensure, than you enabled "Follow system keyboard layout" in X11->Preferences->Input tab.

After these manipulations, forwarded through ssh-X11, the GUI of your application will be able to switch layouts, using your usual MacOS shortcut. In my case, Command+Space. Don't forget to restart X11.

Maybe this will help someone ;-)

P.S.: in this example, I worked only with the Russian layout and keymap, so, again, change parameters for your own!