How to NOT show keyboard layout chooser popup when changing language in GNOME 3

It is possible by querying gnome-shell via its JS interface with gdbus call (src).

The following script will alternate between two configured input sources. Easy to modify if you have more.

#!/usr/bin/env bash

cur_idx=$(
        gdbus call \
                --session \
                --dest org.gnome.Shell \
                --object-path /org/gnome/Shell \
                --method org.gnome.Shell.Eval \
                "imports
                        .ui.status
                        .keyboard
                        .getInputSourceManager()
                        .currentSource
                        .index" |
        cut -d"'" -f2
)

next_idx=$(( 1 - $cur_idx ))

gdbus call \
        --session \
        --dest org.gnome.Shell \
        --object-path /org/gnome/Shell \
        --method org.gnome.Shell.Eval \
        "imports
                .ui
                .status
                .keyboard
                .getInputSourceManager()
                .inputSources[$next_idx]
                .activate()" \
        &> /dev/null

Make it executable with chmod a+x </path/to/script> and you may then bind it to a custom shortcut key:

Open Settings -> Devices -> Keyboard and click the '+' choice-button at the bottom to assign the script to some shortcut

(For Gnome < 3.x: Settings -> Devices -> Keyboard -> Custom Shortcuts).


The overlay appears if you press and hold a bit longer. A quick press and release should change the layout without showing the overlay.

As a workaround you may set another keyboard shortcut to switch layouts, see this for reference: Ubuntu 17.10 can't change the input switching shortcut to alt+shift.