Grave/Backquote key only toggles layout one‐way under Wayland (Stop working since 25.0.0)

Hello, Manjaro users,

Info:

I’ve run into a issue on my Manjaro KDE Wayland setup. I want to use the grave/backquote key (`) to toggle between English (US) and Thai layouts, but it only ever switches in one direction (US → TH) and then stops working until I manually switch back. Under X11 this “grp:grave_switch” option worked perfectly, but under Wayland it seems to be broken.


Manjaro Version:

Latest version that work: 24.2.1 (Grave-Key layout switch is working fine)
The version that started to break: 25.0.0

Manjaro version above refer by (sourceforge) the original KDE ISO

My setup

  • Distro: Manjaro KDE
  • Layouts: US (first), Thai (second)
  • Configured via:
sudo localectl set-x11-keymap us,th '' '' grp:grave_switch
  • Verified:
localectl
  X11 Layout: us,th
  X11 Options: grp:grave_switch
  • Keycodes (libinput):
event2 KEY_GRAVE (41) pressed → released
//That mean my keyboard Grave-key button is working in Wayland

Under X11 everything toggles cleanly back-and-forth; under Wayland it only fires the “next‐group” once, then reverts to emitting a literal backtick instead of cycling back.


What I suspect

This looks like a limitation or bug in xkb (libxkbcommon/Wayland). I’ve even located similar upstream reports/update

  1. xwayland: Don’t run key behaviors and actions (merged 4 months before my setup stop working) ← Maybe this is a problem?
  2. SetGroup xkb action not working on Xwayland (5 Years ago. someone in comment mention on url #1 above)

My questions

  • Has anyone else on Manjaro KDE Wayland run into this “one-way” grave-key toggle (or similar)?
  • Is this a bug of xkb or wayland. and I need to wait for the upstream?

PS.

  • Thanks in advance. I’m still new to Linux and Manjaro (4 Years). This is beyond my knowledge
  • Also In my country (Thailand) we use Grave-key is change to keyboard input (US ↔ TH) so if someone can fixed this problem it’s very helpful for Linux in Thailand community (In Windows OS we use grave-key for switch keyboard input)
  • I’m also have a github (GitHub - tackleza/linux-grave-key: Grave Key Layout Switcher — Toggle US⇄TH layouts with the grave (`) key on X11 and Wayland.) the script that allow user to install “Grave Key Layout Switcher” for Linux
  • If you need more information, just let me know. I’m happy to provide anything that helps. All replies and suggestions are very welcome!

Thank you, :heart:
Tackle

Thanks for including that, because by default there’s no option to use grave for changing layouts.

So this is your own project?

I think you’re better off asking the devs for xkeyboard-config. Perhaps they’d even be willing to add it as a default option.

Alternatively there’s a way to override the files owned by xkeyboard-config, but it only works with Wayland.

If memory serves there are two locations you can use, $XDG_CONFIG_DIR/xkb/ (aka ~/.config/xkb) and /etc/xkb. This is a blog post about it from one of the xkeyboard-config devs.

EDIT:

I’ve had a look at your repo. As I’m sure you’ve found out, those files are owned by xkeyboard-config and will be overwritten every time that package gets updated. Overriding is better, but only works for Wayland.

If lots of people use it, then the proper way would be to get it included in xkeyboard-config.

However the rules files in their repo are intermediate files and won’t match what you’ve done so far.

1 Like

Hello dmt,

Thank you for the reply.

that’s code really old and it’s been used in Linux Thailand comminity for a long time (since ~2010), the original link is already gone. So I maintenance it and put on github. (previously hosted it on my own website)

I’m still new to open source community. Also I don’t have so much knowledge how to do request properly to make that grave-key to be in main xkeyboard-config since i don’t know it meet the requirement or not. and right now in windows 11. it’s quite hard to setup grave key for Thai user. since Windows 11 is now remove Control panel (The article how to setup grave key in Windows OS https://touchpoint.in.th/change-input-language-windows11/)

I’d really appreciate it if you could help forward this to the developers of xkeyboard-config, since I don’t have an account on freedesktop.org, and honestly, that site feels a bit scary to me. (If you think this is ok to be in the default config of xkeyboard-config)

Lastly. I’m doing more debug of this issuse

  • Try to reproduce this problem on 25.0.1 and 25.0.2

I’ll post the result here after I finished my testing

Thank you, :heart:
Tackle

Hello, Manjaro users & moderator

I’ve test the previous Manjaro version and found out that…

  • 24.2.1 → This version is working fine :white_check_mark:
  • 25.0.0 → This version is break my setup :x:

//Create new reply due to previously. I write post with wrong version of Manjaro.
//also I’ve edited the typo version first post

All the package version refer by Original Manjaro KDE ISO from sourceforge

As I said. x11 is working fine. but break in Wayland :pleading_face:
any help or advice is appreciated

Thank you, :heart:
Tackle

Then it’s out-of-date.

I played around and got it working. Here’s the updated version, hopefully I remembered everything :crossed_fingers:

Please test it and let me know if it works for you, if so I’ll create a pull request so you can easily merge it into your repo.

In time it will need updating again, in fact it should be updated every time xkeyboard-config modifies one of those files. If you can say for sure that lots of people use it then it should probably be added into xkeyboard-config, but I’m not sure they’ll like it as it’s replacing a normal key.


It works with any layouts not just US and TH, so perhaps update the description to be more accurate. :man_shrugging:

Grave Key Layout Switcher — Switch layouts with the grave (`) key on X11 and Wayland.

2 Likes

Hello, dmt. :wave:

Yes, i’ve test your code and it’s working perfectly. :white_check_mark:
That’s a magic, please create Pull requests that would be amazing

Also, maybe you have to edit “script.sh” a little bit. since you have removed “xkb”
Maybe in the future i’ll setup some “git action” to perform auto update for this (just a hotfix for now, or until xkeyboard-config come with grave-key as default)

PS. This problem make me up all night until 5:00 am. try to find solution. I’m fight with xkb-config all night :rofl:

PS #2. In Windows OS. Yes. We use grave-key for a long time, since I was born (from the pic we need to select Grave-Accent on the left. and on the right Not Assigned) that pics from the internet. I don’t use Windows any more :slight_smile:
image

This makes it easier for people to move to Linux, especially if they’re used to using the grave key to switch keyboard layouts.

Thank you, :heart:
Tackle

1 Like

Great, I’ve created a pull request which also includes :arrow_down:

Yep, it was late and I forgot about that one.

I’ve modified it so you can optionally install it just for Wayland, the benefit is that you only need to do it once (updates won’t overwrite it).

# only use one of these
./script.sh    # install for both X11 and wayland

./script.sh wayland    # install for wayland only

I haven’t tested it though, so let me know if it needs more work.

Yeah it can take a while, it’s not a particularly easy system to learn.

It took me 2-3 hours, and I’ve done this kind of thing before, but in my defence I had to refresh my memory and I was doing everything manually (no script).

You’re welcome. :smiley:

Hello, dmt :wave:

Here was a small problem if user didn’t define the “wayland” option, then the script will error as below.

Run → sudo ./script.sh
Output → ./script.sh: line 18: $1: unbound variable

If you prefer to fix the script first, then create pull request is ok. or you can create pull request right away, then i’ll fix that problem and I’ll take care of the rest. since you already fixed the hardest part already :white_check_mark:

Sorry, didn’t see that you already created pull request

I hope someone, or maybe you can contribution the grave-key to xkeyboard-config so Linux user can have “Grave-key” for keyboard layout switch out of the box. (with out manual install this script) I’m not good enough to contribution on freedesktop.org

Thank you for contribution this hotfix :heart:
Tackle

That’s caused by the u in set -euo pipefail.

I never really use set, it can be useful but it’s not normally needed. I’m not sure that line really adds much to the script.

Anyway for now I’ve just removed the -u, there’s a new pull request for you.

จริงๆ แล้วผมชอบใช้ AltCaps Lock เพื่อเปลี่ยนภาษานะครับ

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.