198

When I try to set the default combo for switching to different language layouts in my keyboard from Shift+Super+Space to Alt+Shift I can't.

I used to have this combo since Ubuntu 14 and even before that when I used to have Windows. Now for some stupid reason it does not allow (actually nothing happens its not like I get an error or the combo is used elsewhere). How could I bypass this bug?

pomsky
  • 68,507
papajo
  • 2,977
  • 5
  • 19
  • 29
  • 2
    Super+Space for switching input languages is the dumbest idea I have ever met on Ubuntu. In most of cases I end up with Search window over my workspace instead of other input language And even worth that Ctrl+Shift tweak breaks every shortcut in every application – mevsme Jun 15 '21 at 08:02
  • yeah, thanks to Super+Space - lost a fast access to "tab" part of the keyboard so probably Alt+shift is the best, maybe Ctrl+Shift is fine also. Hey, we have a thumb finger which is quite flexible, however our little finger is really little. When someone proposes me to press the smallest key (Super) with the smallest finger (little finger) where there are different way better solutions, total insanity )))

    So obviously little finger is ideally fit to shift keyboard which is the largest (so far in my three keyboards) and the other key should be either alt or space.

    – Nusrat Nuriyev Nov 11 '21 at 13:33

4 Answers4

296

You may use (GNOME) Tweaks to achieve your goal. First install it by running

sudo apt install gnome-tweaks

(on Ubuntu 18.04 and later) or

sudo apt install gnome-tweak-tool

Launch Tweaks and go to Keyboard & Mouse section. Click on the "Additional Layout Options".

enter image description here

A new window should pop up. Look for "Switching to another layout" and expand it. Then check the "Alt+Shift" option.

enter image description here

pomsky
  • 68,507
  • 15
    What a mess.. and I am lucky since there are only hardcoded options and the one I want is in there.. :P I already miss unity ... Thanks m8! Also such a cute puppy! ^^ – papajo Oct 22 '17 at 12:58
  • 5
    Also it is well known bug 1218322. Only gnome-tweak-tool solve this problem. – N0rbert Oct 22 '17 at 16:07
  • @N0rbert Are you sure Tweaks is the only way? Not possible with dconf/gsettings? – pomsky Nov 01 '17 at 09:18
  • By 'only' I mean GUI for average and newbie users. Setting it from dconf/gsettings may be possible too. – N0rbert Nov 01 '17 at 20:15
  • 1
    This does switch languages, but when I press Alt+Shift, Alt key press is handled by the active application. For example, it opens menu bar in Firefox. It makes switching languages very distracting every time. What am I doing wrong? – user502144 Nov 20 '17 at 18:49
  • 2
    @user502144 You're not doing anything wrong, that's a GNOME issue, it triggers on-press instead of on-release. See this for a not-so-elegant workaround: https://askubuntu.com/a/973906/480481 – pomsky Nov 20 '17 at 18:53
  • What about switching to the previous input source? Is that possible to set as, say, "Ctrl + Alt + Shift"? Having to cycle through them all becomes a bit annoying with 3 or more sources. – voithos Dec 11 '17 at 06:22
  • Thank you very much - that helped me to disable Alt-Shift (it broke other application hotkeys) – Ivan Klass Dec 18 '17 at 06:59
  • Hey, what theme is this, it looks awesome? – Tony Bogdanov Jan 21 '18 at 23:54
  • @TonyBogdanov It's a modified Arc theme, but I forgot from where I got it. – pomsky Jan 22 '18 at 10:48
  • 3
    What I wanted was exactly the opposite - to free this key combination as it was messing up with my PHPStorm IDE's shortcuts, and the gnome tweak tool was the only way to do it (for me at least). This shortcut was enforced after an update which asked me if I wanted to enable this key combination... I don't remember clearly the type of the update. Even though I would like to have alt + shift for language switching, it does not behave exactly as the windows version and interferes with other short keys which use alt + shift, like for instance "alt + shift + up" in PHPStorm. – vivanov Aug 23 '18 at 19:35
  • When I do it via Tweaks, it is not persisted. The setting disappears after a reboot. – yuranos Oct 10 '18 at 13:53
  • @yuranos87 Sorry, cannot reproduce! :( Works fine here even on 18.04. Did you launch Tweaks as root (or in a root session) by any chance? – pomsky Oct 10 '18 at 14:22
  • wow i love this tool – Vlad Nov 23 '18 at 16:02
  • Warning! This tweak lead to bug in JetBrains IDEs. When you press Alt+Shift+Something it will work only like Alt+Shift. It triggers on-press instead of on-release. – Yazon2006 Jun 11 '19 at 06:02
  • Works fine on 18.04 LTS – Mohammad Heydari Aug 10 '19 at 19:51
  • This leads to another bug on Debian - L. Shift + R. Shift then also changes the layout - very annoying and difficult to fix. – Jan Mares Jan 14 '20 at 14:16
  • Using this method, I could switch the input languages back and forth by pressing "Left Alt+Left Shift" repeatedly; however, pressing "Right Alt+Right Shift" works only one time and pressing it again does not work (i.e. it does not switch back to the previous language). And the problem is I am used to the right combination for switching languages. – today Jan 29 '20 at 19:43
  • gnome tweaks worked for me only with some other combinations but alt+shift on Ubuntu 18.04.4. – y.bregey Jun 07 '20 at 18:01
  • Selecting Alt+Shift will not work if you press Shift first. And there is no option Shift+Alt in the settings. That's a bit of a bummer – undefined Jan 14 '21 at 08:28
  • 1
    Just installed Ubuntu 22, and this solution only partly works unfortunately. a) Changing layout with alt+shift does work, but the change doesn't show up on the top bar; b) An English language layout seems to have auto-installed itself (normally I have French and Greek only). – Giorgos Sfikas Dec 23 '22 at 08:06
  • Ubuntu 22: For anyone having trouble with changing layout, but not actually displaying it in the top bar: check this answer - https://askubuntu.com/a/1407683/1183873 – trckster Apr 26 '23 at 14:21
  • Anyone using Wayland: it does not work on current gnome (mid 2023). The gsettings-based solution (see below) works, but only in gnome. – peterh Aug 12 '23 at 21:20
144

You can achieve this using gsettings (command-line configuration tool).

  1. Set forward switch to Shift+Alt(left)

    gsettings set org.gnome.desktop.wm.keybindings switch-input-source "['<Shift>Alt_L']"
    
  2. Set backward switch to Alt+Shift(left)

    gsettings set org.gnome.desktop.wm.keybindings switch-input-source-backward "['<Alt>Shift_L']"
    

To see the current setting value use get command:

gsettings get org.gnome.desktop.wm.keybindings switch-input-source
gsettings get org.gnome.desktop.wm.keybindings switch-input-source-backward

Examples of other key bindings:

<Primary>space, Alt_R, <Shift>Control_R, <Shift><Super>space

Changes will take effect immediately.

pomsky
  • 68,507
  • 15
    This is a nice way to achieve the desired change, but the instructions create a mapping that is unnatural for Windows users: you have to first press shift and then press Alt. To use the natural Windows sequence, change "['<Shift>Alt_L']" to "['<Alt>Shift_L']" and similarly for the backwards. Works just as it should. – laugh salutes Monica C Apr 18 '18 at 09:55
  • This approach should be preferred over gnome-tweaks, because with gnome-tweaks there is one side effect where in certain apps (like slack) using alt+shift not only changes the language, but also looses you the focus from the app. – Todor Jan 27 '20 at 10:19
  • 4
    On ubuntu 19.10 this had the required effect, in contrary with gnome-tweaks which didn't seem to be working for alt+shift – Jonathan La'Fey Feb 19 '20 at 07:35
  • Brilliant way to achieve this. Worked instantly on Ubunu 18.04.3 LTS with Unity desktop. – bluepearlsky Apr 02 '20 at 10:30
  • it doesnt work on my side. i have unchecked the ckeckbox as on the screen above and run in the terminal these two gsettings commands, but when i click alt+shift or shift+alt nothing happens and layout not changed... how to force this gsettings to work ? – Eugene May 26 '20 at 22:31
  • 2
    Works in Ubuntu 20.04 LTS. The accepted answer with Gnome Tweaks has a bug when Shift+Shift change keyboard as well https://gitlab.gnome.org/GNOME/gnome-tweaks/-/issues/145 – Arxeiss Jun 01 '20 at 09:00
  • the only one that worked for me on Ubuntu 18.04.4. thanks! – y.bregey Jun 07 '20 at 17:59
  • 1
    @laughsalutesMonicaC On Windows, you can press either of the keys first. I'd actually like to see that on Ubuntu as well. Having used Windows for so long, I am used to pressing shift first since it's a bigger key on my keyboard and right next to my little finger. – undefined Jan 14 '21 at 08:34
  • Note that this setting completely hogs up Alt-Shift, making it impossible to use in e.g. Alt-Shift-Tab. See bug #36812. – rustyx May 24 '21 at 14:12
  • 3
    Still cannot anwer with my low credits but it's: gsettings set org.gnome.desktop.wm.keybindings switch-input-source "['Shift_L', 'Shift_R', 'Alt_L', 'Alt_R']" – rubmz Nov 12 '21 at 20:12
  • 3
    @rubmz: Thank you! I am running Ubuntu 22.04.1 LTS, and this solution is the only one that works. All others fail. – Helen Craigman Nov 26 '22 at 12:38
  • @rubmz thank. your command is working on Ubuntu 22.10 also. – Sai Naw Kham Mar 06 '23 at 13:48
  • In Ubuntu 22.04, this was the option that worked for me. gnome tweaks was acting weird and had to press the combination several times. – Joseph Bani Dec 27 '23 at 05:23
11

Ubuntu 20.04, gnome flashback, the gsettings option didn't work for me. This fixed the problem (copied from my other machine):

gsettings set org.gnome.desktop.input-sources xkb-options "['grp:alt_shift_toggle', 'grp_led:scroll', 'lv3:switch']"

Keyboard shortcuts still show Super+Space combination, and it still works, but Alt+Shift works as well.

wjandrea
  • 14,236
  • 4
  • 48
  • 98
Marat
  • 233
  • setting xkb-options allows layout switching without the window losing focus. I remember we used to do this using x11 configuration files. It is good to know that we can override it using gsettings. – pwned Feb 20 '23 at 08:42
5

I am running Ubuntu 22.04; the problem exists here as well; all answers and suggestions fail here except @rubmz's comment above:

gsettings set org.gnome.desktop.wm.keybindings switch-input-source "['<Alt>Shift_L', '<Alt>Shift_R', '<Shift>Alt_L', '<Shift>Alt_R']"

wjandrea
  • 14,236
  • 4
  • 48
  • 98
Helen Craigman
  • 201
  • 3
  • 12