Reliable keyboard layout switching with Caps Lock

In my Ubuntu 15.10 I set Caps Lock to switch keyboard layouts in System Settings > Keyboard > Shortcuts > Typing > Switch to next source.

But every time I press Caps Lock it still capitalize keyboard for a split second (and Caps Lock LED blinks), then it back to non-capitalized keyboard and finally switch layout. But if I press any key after pressing Caps Lock and before layout switching, the layout doesn't switches at all, and moreover my keyboard remain capitalized.

I very often switch keyboard between English and my native language, and typing very fast, so almost every third switching I capitalize keyboard instead of switching layout. It's very big trouble for me. Hot to fix it?

Update (18 Sep 2016): The bug is still exists in 16.04.


There is ancient bug on Launchpad, which contains workaround: https://bugs.launchpad.net/ubuntu/+source/unity-control-center/+bug/1343327

Maybe it'll help. But it did not help to me (U 14.04.4).


Starting from Ubuntu 13.10, Unity/Gnome moved the keyboard layout changing control from X server to higher level tool: unity-settings-daemon/gnome-settings-daemon plugin to add support for multiple X input methods. So the layout change function in X is just disabled.

Same for Caps key, X interprets it as capital lock. When you assign it to layout changing in Unity settings. It will do both as X is not aware of that. So you have to disable caps function in X.

  • The workaround explained in bug report mentioned by Alex.O seem to do that. Which is the same as running:

    gsettings set org.gnome.desktop.input-sources xkb-options "['caps:none']"
    

    caps:none means Caps Lock is disabled, to see all Caps key X supported functions, try:

    more /usr/share/X11/xkb/rules/xorg.lst | grep caps
    
  • To get default function back:

    gsettings reset org.gnome.desktop.input-sources xkb-options