Score:1

Non-cyclical keyboard layout changes in Ubuntu

in flag

How do I use non-cyclical keyboard layout changes in Ubuntu 22?

enter image description here

I've tried using Gnome-tweaks to no avail. Using toggle shortcuts works. E.g. if I bind Caps Lock (grp:caps_toggle in setxkbmap-speak) it works as expected - cycles through layouts. But when I use Left Ctrl to first layout; Right Ctrl to last layout those key combos do nothing.

What I want:

  • press key or key combination A - get layout A
  • press key or key combination A - no layout change, still layout A
  • press key or key combination B - get layout B

I assume setxkbmap options below (which are selectable in Gnome Tweaks too) are a way to get what I want

grp:shift_caps_switch Caps Lock to first layout; Shift+Caps Lock to last layout
grp:win_menu_switch  Left Win to first layout; Right Win/Menu to last layout
grp:lctrl_rctrl_switch Left Ctrl to first layout; Right Ctrl to last layout
grp:lctrl_lwin_rctrl_menu Left Ctrl+Left Win to first layout; Right Ctrl+Menu to second layout

Please, help me find the answer

Gunnar Hjalmarsson avatar
uz flag
Assuming you use Ubuntu on Wayland, it's worth mentioning that the XKB way to switch keyboard layout doesn't work well in 22.04. Your observation may be a variant of [this bug](https://launchpad.net/bugs/1956916).
bizzz avatar
in flag
Thanks, it looks like this bug is something very similar to what I am experiencing. Though people there seem able to fix the symptoms by switching to XORG (instead of Wayland), which does nothing for my problem unfortunately.
Score:1
in flag

I'm still searching for a solution that will allow me to use combos like Left Ctrl + Left Super.

Meanwhile, if you're OK with using a more limited shortcut possibility space, here's a variant solution, using default tools:

Note: it will break your default layout cycling.

  1. Press Super (win)
  2. Type keyboard, go to Keyboard settings
  3. Scroll down, go to Keyboard shortcuts
  4. Scroll down, go to Custom shortcuts
  5. Add a custom shortcut
    • Name: anything you like
    • Command: setxkbmap -layout us (change us to the layout you want)
    • Shortcut: set a shortcut you like
  6. Repeat adding shortcuts for as many layouts as you like
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.