4

I am using Ubuntu 14.04 and have defined 4 languages. I am currently using left alt-shift to switch between them.

I would like though to define a specific key sequence for each one of the languages (in windows this is possible). For example, press Ctrl+1 for English, Ctrl+2 for Spanish, Ctrl+3 for German, etc.

Anybody knows a way to do that?

1
  • Hey, I see you marked this question as duplicate, which is indeed. But this question was asked a few days BEFORE the other question was asked (and answered). So maybe the "This question has been asked before and already has an answer." is not exactly accurate :-)
    – kaposto
    Sep 5, 2018 at 13:18

2 Answers 2

3

I do not think it is directly supported, but you can use the command line setxkbmap with the generic custom shortcut keys.

You have first of all to find the exact command that sets you keyboards; in my case I have

 setxkbmap es -variant standard_tlde 

for the my custom Spanish keyboard and

 setxkbmap us -variant altgr-intl

when I want the US-AltGr international one. The exact name of the variant is found in /usr/share/X11/xkb/symbols/es (or us, or it --- change as needed); for example, for the US variant I use, which is called "English (international AltGr dead keys)", it's here:

excerpt of US xk symbols key

When you have it, open Settings -> Keyboard -> Shortcut Tab, go on Custom Shortcut, and add (with the +) the shortcuts:

keyboard settings

Type a name and the command you need. After that, you need to click on the "Disabled" word and type your shortcut:

keyboard settings 2

And you're set.

Notice though that keyboard layout switch is plagued by several and important bugs, so you will have to use a lot of patience...

1

Input sources on Ubuntu can be set depending on the order they appear in the list. For instance, here is how my list of input sources look like.

enter image description here

The numbering starts at 0. This means that English is number 0 , Pinyin is number 1, and Russian is 2.

Knowing that, we can use gsettings command to set each source via it's number.

For instance, I could bind CtrlAlt1 to set English via command

gsettings set org.gnome.desktop.input-sources current 0

For Pinyin, I could use CtrlAlt2 and command

gsettings set org.gnome.desktop.input-sources current 1

Hope you get the idea. Good luck !

Not the answer you're looking for? Browse other questions tagged .