A X11/Wayland extension to quickly switch keyboard language layouts, that bypass the switcher popup and preserves the focus of the active window/widget.
Here’s a polished version of your installation instructions:
The easiest way to install the extension is through the GNOME Extensions website.
If you prefer to install directly from GitHub, you can use the following command:
git clone https://github.com/ankostis/gnome-shell-quick-lang-switch ~/.local/share/gnome-shell/extensions/quick-lang-switch@ankostis.gmail.com
In case a new Gnome version is released and the developer is unresponsive, you will need to update your metadata.json file to include the new version number. For example, if the new Gnome version is 48, modify this JSON file as follows:
nano ~/.local/share/gnome-shell/extensions/quick-lang-switch@ankostis.gmail.com/metadata.json
... and append your Gnome's version into the "shell-version" property:
"shell-version": ["46", "47", "48"],
After installation, ensure the extension is enabled by running:
gnome-extensions info quick-lang-switch@ankostis.gmail.com
gnome-extensions enable quick-lang-switch@ankostis.gmail.com
If the first command indicates that the extension does not exist, please log out and log back in (this is required for Wayland).
The language switcher popup by default takes ~0.7sec to appear, meaning that roughly 2-4 strokes are lost till the switch completes. This affects heavily users typing languages with non-latin based alphabets (e.g. Greek, Cyrilic, Arabic, Japanese), particularly when writting technical documents.
Furthermore, the popup messes with the focus of the active window/widget, (eg. IntelliJ's search popup gets closed, the active widget loses focus when the screen is shared, etc).
Hence the many relevant questions on the web:
Since gsettings cannot reliably switch keyboard layouts both on X and Wayland,
some of the recipes above suggest binding a "custom keyboard shortcut" to a bash-script
performing the switch through dbus command, which bypasses the popup.
Unfortunately since Gnome-shell v41 (e.g. pushed downstream to Debian unstable "SID" roughly on Sept 2021)
dbus no longer allows calling method org.gnome.Shell.Eval with arbitrary code,
due to security concerns.
The workaround to keep using dbus is to use a custom eval method,
but this extension cuts to the chase.
Furthemore, since the extension does not define a custom-shortcut,
all keyboard customizations with gnome-tweak-tool/setxkbmap in X11 or Wayland
still work fine, on all Gnome versions.
A better solution would be to modify the original ui/status/keyboard.js code
to skip the switcher-popup based on some new boolean preference (e.g. settable from Tweaks ),
as requested by gnome-shell#2945 issue.
If you want to switch between multiple layouts immediately, ie. without cycling through them, there is now (June 2023) Osamu Aoki's extension.
TIP: to facilitate typing while switching language, you may assign
the "Switch to next/previous input source" keyboard shortcut to a single keystroke,
like [SysRq/Print] or [CapsLock] keys.
![Screenshot of Gnome Tweaks tool to enable **[CapsLock]** as language switcher](https://github.com/ankostis/gnome-shell-quick-lang-switch/raw/main/CapsLockSwitcherSettings.png)
journalctl -fg 'quick.Install the extension locally:
bash
cd ~/.local/share/gnome-shell/extensions
ln -s <your-project-folder> quick-lang-switch@loca
Note: Unfortunately testing the extension under Wayland in a nested gnome-shell, as gnome-shell docs suggest, does not work for the language switch key, because it is consumed by the outer shell; you must re-login to reload your changes.
Cycle with 3+ layouts installed.
Check both Xorg and Wayland.
Discover the latest version present in the Gnome-extensions site (link above).
version + 1.git tag -sm '<msg>' v<latest-release + 1>git push origin main --tag-z option sets the git-hash as zip's comment):bash
git rev-parse HEAD | \
zip ../gnome-shell-quick-lang-switch-$(git describe).zip \
-z \
extension.js \
metadata.json
event arg (so broken for v48 shell).event argument into /ui/status/keyboard.js/InputSourceManager._switchInputSource() which broke old compatibility.metadata.js as working also in gdm & lock-sreen.gdm is not allowed on ego extensions since they are not going
to be installed as system extension.NOTE: the new code is incompatible with previous gnome-shell-44 and below. In case bugs are discovered, old releases would have to be bugfixed separately.
Extension --> QuickLangSwitchExtensionreturn in the 2 bail-out/error conditional branches,
indeterminate action would have happen then (not really tested :-().switch-input-source-backward
(fix #4.
thanks to Yevhen Popok, @PotatoXPC)version: 3.28, 3.30, 3.34, 3.32, 3.36, 3.38, 40, 41, 42, 43
version: 3.28, 3.30, 3.34, 3.32, 3.36, 3.38, 40, 41, 42
version: 3.28, 3.30, 3.34, 3.32, 3.36, 3.38, 40, 41
version: 40, 41
switch-input-source shortcut to direct switchIt re-binds the 'switch-input-source' shortcut:
InputSourceManager._modifiersSwitcher, andInputSourceManager._switchInputSource method.
Note, it won't reset it to any previous monkeypatches.$ claude mcp add gnome-shell-quick-lang-switch \
-- python -m otcore.mcp_server <graph>