Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In Windows it is possible to arrange your keyboard layouts in 2 levels as following:

  • 1. English:
    • 1.1. English US
    • 1.2. English UK
  • 2. German

And you are able to:

  • a) switch directly between 1. and 2. using Alt+Shift.

  • b) switch directly between 1.1. and 1.2. using Ctrl+Shift (when 1. is chosen).

How can I arrange the same setup in Ubuntu if is it possible?

Thank you for your help in advance!

share|improve this question
up vote 3 down vote accepted

There are many shortcuts to choose to switch between keyboard layouts, but none fits with what you want.

Anyway, it can be done using some tricks.

a) Switch directly between English (English US, English UK) and German

First, create the script, let's call it change_layouts:


en_layouts="['us', 'gb']"

current_layouts=$(gsettings get org.gnome.libgnomekbd.keyboard layouts)

if [ "$current_layouts" = "$en_layouts" ]; then
    gsettings set org.gnome.libgnomekbd.keyboard layouts "$de_layouts"
    gsettings set org.gnome.libgnomekbd.keyboard layouts "$en_layouts"

Save the script in your ~/bin directory and don't forget to make it executable:

chmod +x ~/bin/change_layouts

Now you can test the script in terminal. Run it more times to see how it works.

Second, add a custom shortcut for this script. Go to System SettingKeyboardShortcutsCustom Shortcuts and follow the instructions from the below image:

add custom shrtcut

For some reasons, at least in my case, if I set the Alt+Shift shortcut, this will not run the script. Maybe this is a bug. But there are many other choices, like Alt+Shift+1.

b) Switch directly between English US and English UK (when English is chosen)

Go to System SettingKeyboard LayoutOptionsKey(s) to change layout and tick Ctrl+Shift:

Key(s) to change layout


share|improve this answer
Great! Thank you very very much! There is still one little glitch that I would like to fix. When there is only one layout (in the de_layouts), the icon for displaying the current language disappears. I've created a workaround by putting the entry 'de' two times: ['de', 'de'] but it is a bit of an ugly fix. I would be happier if there is a way for the keyboard layout icon not to disappear when it contains only one layout. And thanks again! :) – Anton Petrov Oct 9 '13 at 13:15
@AntonPetrov The problem is that there is no way for keyboard indicator to be shown if there is only one layout set. This is a part of the design. If you had asked, I would have offered you the same solution: de_layouts="['de', 'de']" or maybe de_layouts="['de', 'de\tnodeadkeys']" – Radu Rădeanu Oct 9 '13 at 13:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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