Hold a key to temporarily switch keyboard layout?

I recently upgraded to Ubuntu 13.10. In Ubuntu 12.04, I was able to define a key which, while holding it, temporarily switched to a different keyboard layout. I haven't been able to find a way to get that functionality in 13.10: the only option seems to be to toggle between different layouts using the "Switch to next source" shortcut.

Is there a way to get the "hold a key to temporarily switch to a different keyboard layout" functionality in 13.10?


Solution 1:

  • With Gnome 3.6, layout setting method changed. So Ubuntu 13.10 and later, has different behavior then before. This should work well in Gnome (Tested Ubuntu 13.10/14.04).

  • Unity seems not to use xkb-options (Tested it in Ubuntu 13.10/14.04). Even using for example:

    setxkbmap us,ara -option grp:rctrl_switch
    

    It just works for seconds, then it is reseted.

    Edit /usr/share/X11/xkb/symbols/pc, Remove rctrl from ctrl binding:

    //modifier_map Control{ Control_L, Control_R };
    modifier_map Control{ Control_L };
    

    again:

    setxkbmap us,ara -option grp:rctrl_switch
    

    It just works, till it I use change my layout using Super+Space or directly from indicator. So as workaround for Unity, Disable layout toggle shortcuts (layout indicator could removed too) then add a -option grp:..._toggle to setxkbmap .

So for Gnome:

  1. Use dconf-editor → org → gnome → desktop → input-sources

  2. Add setxkbmap options to xkb-options, example:

    ['grp:rctrl_switch']
    

To see all possible options:

more /usr/share/X11/xkb/rules/xorg.lst | grep grp:

enter image description here