16

Since I installed 17.10, when switching language with the assigned keyboard shortcut I get this switcher "window" that obstructs me from typing for a couple of seconds. And yes, a couple of seconds is a huge amount of time when switching languages a lot.

huge focus-grabbing language-switching indicator

This happens both in X11 and Wayland but doesn't happen (the obstructive window will not appear) when I switch language by clicking on the lang indicator on top bar. Is there any way to tell this window "please go away"?

pomsky
  • 67,112
  • 21
  • 233
  • 243
nikosal
  • 171
  • 6

3 Answers3

4

I've built the Quick Lang Switch Gnome-shell extension exactly to avoid the switcher popup - now switching languages happens instantly. Plus, it does not require a custom-shortcut (the regular one changes behavior), so login-screen is not affected.

Disclaimer: I am the developer of the Quick Lang Switch...

andrew.46
  • 37,085
  • 25
  • 149
  • 228
ankostis
  • 181
  • 11
  • If it's a bug, please file an issue in [the extension's repo](https://github.com/ankostis/gnome-shell-quick-lang-switch). – ankostis Feb 05 '22 at 23:03
  • Sorry, you're right; and the problem fixed itself somehow. Thanks for the plugin! (Deleting my previous comment) – Bach Feb 07 '22 at 02:54
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).

ankostis
  • 181
  • 11
Dmitry Zotikov
  • 351
  • 1
  • 3
  • 7
  • 1
    Thank you, the script works flawlessly in SID+ latest Gnome-3. – ankostis Apr 17 '20 at 07:01
  • 1
    Unfortunately, due to [security concerns](https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3943), *dbus* can no longer call method `org.gnome.Shell.Eval` with arbitrary code, since Gnome-shell v41 (e.g. pushed downstream to *Debian unstable "SID"* roughly on Sept 2021). You need an extension [like this](https://extensions.gnome.org/extension/4559/quick-lang-switch/) which additionally is much more responsive. – ankostis Oct 21 '21 at 16:25
3

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.

pomsky
  • 67,112
  • 21
  • 233
  • 243
  • Yes, I could do what I wanted to, by assigning a new shortcut as you proposed. With my previous selection (that was pressing F2/F3) this window (the overlay, as you call it) would appear even if I pressed keys for a brief moment. Thank you. – nikosal Nov 04 '17 at 16:04
  • I had always re-assigned lang switching to the F2/F3 keys instead of alt+shift, obviously because I prefer "one key" stroking instead of a combination. When I upgraded to 17.10 the F2/F3 switching was giving me this overlay. When I assigned a new key (ScrLk) the overlay will not appear, so I am more or less ok (although ScrLk is well away on the right and not comfortable for speed typing). – nikosal Nov 05 '17 at 16:31
  • 3
    I'm pressing the key as fast as humanly possible, and the window still shows up (which is OK), and it steals keyboard focus (which is *not* OK). – Flimm Jun 23 '18 at 17:32
  • @Flimm What 'bout the alternative shortcut (e.g. alt+shift) suggestion? – pomsky Jun 23 '18 at 17:40
  • 2
    Setting another shortcut is forcing users to change common keys , break habits and also break compatibility with other systems. I rather go back to windows. I would not consider anything that comes close to 'design decision - take it or go away' to be a valid solution... – QT-1 Aug 30 '18 at 14:46
  • @user1656671 I know it's very upsetting right? I've got the same issue once switched to the wayland. Switch back to X11 with unity works as expected – ruX Jan 21 '20 at 15:04