This has been asked countless times, so I'll try to be brief.

I have two input layouts, Ukrainian and English, and want:

  • to use Caps Lock for fast switching;
  • not have any delays imposed, I'm a fast typer;
  • not have mode errors:
    • (any number of) CapsLock sets English,
    • (any number of) ShiftCapsLock sets Ukrainian;
  • see the current layout in the standard widget.

I've already tried three (!) GUIs to configure this, the Gnome Settings, the gnome-tweak-tool, the dconf-editor/gsettings. Nothing works. Tweaks crashes randomly.

Enough homework done

I've asked this myself 4 years ago for 14.04 LTS. Since then, that UI popup appeared and all broke. I can now easily configure stateful CapsLock toggle, but even then, it goes with that irritating delay. Basically unusable at times when I need language switched 4-5 times per sentence.

This thread suggests caps:none XKB option as a bug workaround. I've tried that, both with gsettings CLI and dconf-editor, and in combinations with grp:shift_caps_switch XKB option. No dice. Something trumps those core XKB features as it seems.

This thread offers caps:menu XKB option as a hack to be able to bind CapsLock in Gnome Settings → Devices → Keyboard. It kinda works, but A) it gives cyclic/stateful switching; B) I have to wait a decent timeout on every switch.

This thread asks exactly what I need, yet it's unanswered and even worse: closed as duplicate of two other questions (???) none of which are the same, and none of which give me a working solution. What's wrong with you guys?

There's another exact match — alas, unanswered as well!

Wanted: clean solution

  • 1
    What about reputation instead of $ for a bounty, let's say +50 points reputation?
    – karel
    Mar 5, 2019 at 11:15
  • @karel I see nothing wrong with that, however "fresh" questions are not eligible for rep bounty on stackexchange. A bounty can be started on a question two days after the question was asked; please un-downvote.
    – ulidtko
    Mar 5, 2019 at 11:25
  • I didn't downvote. All I did was commented.
    – karel
    Mar 5, 2019 at 11:26
  • Ok. Nevertheless, I did both offered and earned reputation bounties specifically on AskUbuntu. This question is going to get one, too, when it's time.
    – ulidtko
    Mar 5, 2019 at 11:28
  • 1
    @ulidtko I'll try to take a peak at gnome-tweaks-tool. Won't promise if I can dig out anything and will need quite some time, since I'm busy lately, but I'll post an answer if I dig out anything related to gnome-tweak-tool. Feel free to leave me a comment here or contact me in other ways Mar 19, 2019 at 23:11

4 Answers 4


In Ubuntu 18.04, by default there is a option to choose Caps_Lock and Shift+Caps_Lock to achieve the behavior we are looking for, is in gnome-tweaks. But this is not working and could not get the reason why.

enter image description here

I could manage to achieve this behavior by the below workaround.

See this link for a 20Sec Video. https://i.stack.imgur.com/bFSTt.jpg

first check the below commands in terminal whether they are changing the input language.

gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell --method org.gnome.Shell.Eval "imports.ui.status.keyboard.getInputSourceManager().inputSources[1].activate()"


gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell --method org.gnome.Shell.Eval "imports.ui.status.keyboard.getInputSourceManager().inputSources[0].activate()"

well, they are working.

enter image description here

we need to bind these commands to key presses of Caps_Lock and Shift+Caps_Lock

can achieve this with xbindkeys if xbindkeys is not yet installed install it by sudo apt install xbindkeys

  1. create a file .xbindkeysrc in $HOME folder
    touch ~/.xbindkeysrc
  2. to know the keycode/id what ever it is called
    run xbindkeys --key once the white box appears press the Caps_Lock button, do it for Shift button also and copy the keycodes/ids as show below

enter image description here

  1. this step is Optional.. Disable the Caps Lock. See below gif. If caps lock is not disabled.. when you hit the key multiple times it will toggle while you try to change the language. I have Disabled it. but it is based on your interest.

enter image description here

  1. Open the file .xbindkeysrc
    gedit ~/.xbindkeysrc and edit the file like below based on the results of above steps

Change the values in below content according to the results you got in step 2 above. Content:

"gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell --method org.gnome.Shell.Eval "imports.ui.status.keyboard.getInputSourceManager().inputSources[0].activate()""
m:0x10 + c:66

"gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell --method org.gnome.Shell.Eval "imports.ui.status.keyboard.getInputSourceManager().inputSources[1].activate()""
Shift+Mod2 + Shift_L+m:0x10 + c:66
  1. Save the file, Close & Reboot..
  • 4
    OMG it worked! I didn't even need to log-out, evenless reboot (xbindkeys --poll-rc). I also left grp:shift_caps_switch XKB option on — which changed how my key codes are printed (m:0x0 + c:66 ISO_First_Group & m:0x1 + c:66 Shift + ISO_First_Group); no problems from that. Even the keyboard LED shines! Amazing job, you totally should've get this bounty. (gnome-tweaks authors, whoever they are, get a grumpy frown from me & others.)
    – ulidtko
    Mar 19, 2019 at 12:35
  • For older Ubuntu versions next commands for language switching works: Switch to first layout: > gsettings set org.gnome.desktop.input-sources current 0 Switch to second layout: > gsettings set org.gnome.desktop.input-sources current 1 Aug 29, 2020 at 17:01
  • This solution does not change the layout in a super menu (when I hit the Super key and search for launching new applicaton) Jan 9, 2021 at 16:04
  • Unfortunately step (4) above won't work. Since Gnome-shell v41 (~Sept 2021) dbus no longer allows calling method org.gnome.Shell.Eval with arbitrary code due to security concerns.
    – ankostis
    Jul 29, 2023 at 22:55

There is a bug report you can subscribe to:

The bug report reads:

Keyboard panel has options for input switching, but it does not allow to use Caps as language switch.

Steps to reproduce:

  1. gnome-control-center keyboard
  2. Scroll down to 'Typing' section
  3. Click on Switch to next input source
  4. Press Caps

Expected result: Caps Lock key is accepted as switch key Actual results: Caps key is ignored in the selection window.

P.S. Same goes for 'Switch to previous input source' and Shift-Caps key combination.

Bug Workarounds

The bug is currently on the "Wishlist". These workarounds are proposed:

Workaround 1

Found a workaround for this bug:

  1. Install dconf-editor (sudo apt-get install dconf-editor)
  2. Go to /org/gnome/desktop/wm/keybindings/
  3. Select key switch-input-source, turn off "Use default value" and set "Custom value" to ['Caps_Lock']
  4. (Optional) You can also change value for switch-input-source-backward to something like ['Caps_Lock'] (again, turning off "Use default value")

Workaround 2

Another way to do this: 1. Install GNOME Tweaks (gnome-tweak-tool) 2. Open the Tweaks app 3. Switch to the Keyboard & Mouse panel 4. Click Additional Layout Options 5. Use the "Switching to another layout" section

Subscribe to bug report

I would recommend subscribing to the bug report and adding your own experiences. The more people subscribing to the bug report, the faster the solution comes (usually).

  • Workaround 1 doesn't suit my requirements, it gives cyclic switching, which is not what I want. Workaround 2 (Gnome-Tweaks) has been tried and beaten to death; I can make it crash, but can't make it work. Thanks for (yet another) link though.
    – ulidtko
    Mar 14, 2019 at 12:00

Meet clean solution that meets your needs:

Shyriiwook (also available @ GitHub: madhead/shyriiwook). That's a GNOME Shell Extension and I am its author.

This is a very simple, minimalist extension. It doesn't have any GUI. After installing it, a new D-Bus interface would be exposed in your GNOME Shell session. You could query it for the current configuration or call a method to activate the desired layout and that's it:

$ gdbus introspect \
    --session \
    --dest org.gnome.Shell \
    --object-path /me/madhead/Shyriiwook \

node /me/madhead/Shyriiwook {
  interface me.madhead.Shyriiwook {
      readonly as availableLayouts = ['us', 'de', 'jp'];
      readonly s currentLayout = 'us';

$ gdbus call \
    --session \
    --dest org.gnome.Shell \
    --object-path /me/madhead/Shyriiwook \
    --method me.madhead.Shyriiwook.activate "de"

This is easily scriptable, and you can put this command raw into a custom shortcut under the "Settings" → "Keyboard" → "Keyboard Shortcuts" → "View and Customise Shortcuts" → "Custom Shortcuts".

It doesn't have any delays, even the annoying language switch popup is not show.

It's totally stateless and idempotent. When you assign a D-Bus call (like the last one from the example above) for, say CapsLock, any number of presses will set language to a deterministic value (German in the example).

It simply works in recent GNOME versions (I am using 42, but I've also tested on 45). Unlike the other solutions available in the Internet:

  • The setxkbmap doesn't play nice with the GNOME Shell (it doesn't update the language in status area and simply breaks further layout switching until the next reboot).
  • The gsettings set org.gnome.desktop.input-sources current is deprecated and doesn't work anymore
  • The gdbus call … org.gnome.Shell.Eval … is also deprecated due to security implications.

Info for Nerds: Shyriiwook is based on D-Bus, but it doesn't use unsafe and deprecated Eval nor any of its alternatives. It re-implements a similar solution using GJS by accessing the same getInputSourceManager directly.

  • 1
    Awesome, thanks! I'd since switched to KDE, its stock systemsettings allows to configure this in a few clicks. But this extension will of course be useful to GNOME Shell users with similar needs. Well done!
    – ulidtko
    Jan 28 at 19:25

For using [CapsLock] to switch languages, open the Gnome Tweaks tool (install it if not already there) and check "Keyboard & Mouse" \ "Additional Layout Options" | "Switching to another layout" | "Caps Lock". enter image description here

For eradicating the popup delay, install the Quick Lang Switch Gnome-shell extension to avoid the switcher popup and switch languages instantaneously. The extension does not define a custom-shortcut, so all customizations with gnome-tweak-tool/setxkbmap in X11 or Wayland still work fine, on all Gnome versions.

NOTE: this solution does NOT address the "mode errors" (ie. when the switch key is pressed multiple times).

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .