I’m having some issues with switching keyboard layouts in Niri. I can’t tell if this is a Niri bug, or something else on my system is messed up.
Here’s the outcome of my closest attempt I’ve gotten to (I tried to isolate keyboard related changes to a single commit of 5 lines). I am testing with 2 keyboard layouts and no variants.
My current behavior is that I can in theory switch keyboard layouts, but my keyboard still uses the first layout. I’ve tried disabling the xkb changes in either niri, or in the xserver settings, I tried with and without services.xserver.enabled = true, and I am unsure what I’m doing wrong. (I would prefer services.xserver.enabled to remain false in my config if I can get away with it). I have not tried anything in home-manager and would be unsure what to try there.
Essentially, niri says I am using my Romanian layout, but my keys behave as English (US).
$ niri msg keyboard-layouts
Keyboard layouts:
0 English (US)
* 1 Romanian
I’m also unsure how to debug this further, would love to figure that out as well.
The default Romanian keyboard layout is ro(std) not ro. The former is equivalent to us except it has Romanian characters on dead keys. That made it feel like nothing was changing.
It is enough to modify ~/.config/niri/config.kdl. services.xserver.xkb is NOT needed when using niri 25.05.1.
There’s a recent commit in niri which allows it to read xkb settings. Future releases might allow us to configure keyboard layout from either location. Right now follow, the niri docs are correct (provided I’m not dumb enough to use the wrong keyboard).
The keyboard switching is done from niri. Here’s the relevant part in my config.
I just figured out how to do emojis in the niri/language waybar module. Apparently it doesn’t work if you specify both “format” and “format-[lang]” at the same time. Their issue appears to be about matching the rules, and not about what gets printed. I used to just print shortDescription until a few minutes ago.
The input.keyboard.xkb.options thing I had in place. Thanks anyways!
Having to comment format worked! Last night I did not try that, even checked the generated .kdl, and gave up after the timebox ran out. But now it’s solved.