Sway config for multiple keyboard layouts

I’m unable to find much documentation on using multiple keyboard layouts in Sway. The sway-input manpage says

Multiple layouts can be specified by separating them with commas.

But I’ve tried that, and it doesn’t seem to work. Here’s my current working config for a Dvorak layout:

input * {
        xkb_layout "us"
        xkb_variant "dvorak"

If I try to add another layout, like so

input * {
        xkb_layout "us,gr"
        xkb_variant "dvorak,polytonic"
        xkb_options "grp:lctrl_lshift_toggle"

then I just get the standard US keyboard layout when I restart Sway. I would also like to have the standard US layout as an option, but didn’t want to add the extra complication of two variants of the same layout before getting multiple layouts working. I’ve tried xkb_layout "us,us" and xkb_variant "dvorak," and get the same result. I also get the same result if I separate the xkb configuration options out of that block and preface each one with input * .

Is this not the correct way to configure the keyboard layout?

input type:keyboard xkb_layout us,us
input type:keyboard xkb_variant dvorak,

I used to have this in my config to change between qwerty and dvorak US layouts.

I think I had some issues with swappable layouts and interactions with some gtk programs where the keyboard shortcuts looked at the wrong layout and broke things like copy paste, so I don’t have anything like that anymore.

My current setup has me set one layout for the built-in laptop keyboard and one for my external keyboard which is probably all I needed in the past anyway. (also switched to Workman now)

Here’s that if that interests you:

# Pinky4
input "21582:28724:tamanishi_Pinky4_Keyboard" {
	xkb_layout us
	xkb_options compose:caps

# ThinkPad keyboard
input "1:1:AT_Translated_Set_2_keyboard" {
	xkb_layout us
	xkb_variant workman
	xkb_options compose:caps

I don’t actually own a Reform, just browsing the forums in case I get one someday. I use Sway on a ThinkPad T440p.

As for getting the input identifiers, you can find them here:
swaymsg -t get_inputs (I usually pipe it to less to make it easier to search)

edit: I would recommend also asking for help in the #sway IRC channel on libera if you haven’t already.

1 Like