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
:
#!/bin/bash
en_layouts="['us', 'gb']"
de_layouts="['de']"
current_layouts=$(gsettings get org.gnome.libgnomekbd.keyboard layouts)
if [ "$current_layouts" = "$en_layouts" ]; then
gsettings set org.gnome.libgnomekbd.keyboard layouts "$de_layouts"
else
gsettings set org.gnome.libgnomekbd.keyboard layouts "$en_layouts"
fi
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 Setting → Keyboard → Shortcuts → Custom Shortcuts and follow the instructions from the below image:
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 Setting → Keyboard Layout → Options → Key(s) to change layout and tick Ctrl+Shift:
Related:
A confirmed bug in Ubuntu 13.10 prevents users from switching layouts using combinations like Alt+Shift, Caps Lock, Ctrl+Shift etc.
The bug affects many people, its importance is set to "High", so we may expect that an official fix will be released soon. You can subscribe to notifications about this bug on launchpad.net, so that you receive an email when it's done.
Currently, a patch aimed at resolving this issue is being tested. By now it seems to work for most users, though certain problems remain. To install the patch, use the following commands:
sudo add-apt-repository ppa:attente/modifier-only-input-switch
sudo apt-get update
sudo apt-get upgrade
A system reboot was needed in my case to make it work (simple log out and log in may be sufficient).
Note: Originally, the patch was located at ppa:attente/1218322. If you have previously installed it from there, you can first purge it as follows
sudo ppa-purge ppa:attente/1218322
and then execute the three commands above.
Alternatively, you may consider using a combination containing a non-modifier key (a letter, digit, space): try, for instance, Alt+Shift+Space (this will work without installing any patches).
Note that the keyboard shortcuts for switching layouts still do not work on lock screen (it is a separate bug). If you are stuck on lock screen and unable to enter the password because of the wrong layout, simply click the language indicator icon on the right of the password field.
Best Answer
In Ubuntu Budgie 17.04, you would have noticed that using the GUI Settings - Keyboard - Typing - Switch to Input Source does not respond to a ALT+Shift by itself. You need a third keystroke.
However you can go behind the scenes and install the package
dconf-editor
and edit one or both of the following keys to get things working:Go to
org.gnome.desktop.wm.keybindings
change switch-input-source to
['<Alt>Shift_L']
Likewise the key switch-input-source-backward change to
['<Shift>Alt_L']