You are not logged in.

#1 2021-07-28 18:25:47

fobban
Member
Registered: 2020-12-30
Posts: 9

Swaywm problem with multiple keyboard layouts

I have two layouts specified in my sway config, English and Swedish, and used to be able to toggle between then with $mod+space. Part of the config:

input "type:keyboard" {
    xkb_layout us,se
    xkb_numlock enable
    repeat_delay 250
    repeat_rate 30
}

[...]

bindsym $mod+space input type:keyboard xkb_switch_layout next

Now it doesn't work anymore and the layout is stuck in English. I haven't been using the computer very much lately so I can't say exactly when it stopped working.

I can toggle manually with swaymsg input "type:keyboard" xkb_layout se and swaymsg input "type:keyboard" xkb_layout us but when I try to set multiple layouts I get an error:

swaymsg input "type:keyboard" xkb_layout "us,se" # Layout is changed to English; output: Error: Unknown/invalid command 'se'
swaymsg input "type:keyboard" xkb_layout "se,us" # Layout is changed to Swedish; output: Error: Unknown/invalid command 'us'

/usr/share/X11/xkb/symbols contains both us and se.
"sv_SE.UTF-8 UTF-8" and "en_US.UTF-8 UTF-8" are uncommented in "/etc/locale.gen"

I've tried variations with and without quotes, double quotes, single quotes and also checked the Sway - ArchWiki and the Sway Wiki...but can't get it to work sad.

Any help is appreciated.

Offline

#2 2021-07-29 16:56:12

natervance
Member
Registered: 2017-04-20
Posts: 53

Re: Swaywm problem with multiple keyboard layouts

I've found that keycodes get messed up when switching layouts, so my solution (on i3, but it should work on sway) is to let xkb handle it:

exec --no-startup-id "setxkbmap -layout dvorak,us -option 'grp:alt_shift_toggle'"

Of course, substitute dvorak,us for se,us in your case.

Last edited by natervance (2021-07-29 16:57:04)

Offline

#3 2021-07-30 14:35:21

fobban
Member
Registered: 2020-12-30
Posts: 9

Re: Swaywm problem with multiple keyboard layouts

Can't get that to work either.

Putting exec "setxkbmap -layout us,se" in the config didn't help. (Had to remove --no-startup-id as I got "unrecognized option"; guess it's not supported in sway.)

swaymsg exec "setxkbmap -layout us,se" returns same error as before: "Unknown/invalid command 'se'"

My current workaround is a separate keybinding for each keyboard layout, so this isn't really a big issue, more a small annoyance smile.

Offline

#4 2021-07-30 14:38:57

natervance
Member
Registered: 2017-04-20
Posts: 53

Re: Swaywm problem with multiple keyboard layouts

But not even the -option 'grp:alt_shift_toggle' part made it so you could toggle between layouts? It should make it so that pressing alt+shift switches layouts.

Offline

#5 2021-07-30 14:49:49

fobban
Member
Registered: 2020-12-30
Posts: 9

Re: Swaywm problem with multiple keyboard layouts

Nope, that option doesn't make any difference hmm. I've tried other options too, such as grp:win_space_toggle.

Offline

#6 2023-10-16 09:29:59

scippio
Member
Registered: 2007-01-02
Posts: 74

Re: Swaywm problem with multiple keyboard layouts

I have very similar problem after upgrade now sad

One layout works ok:

sway input type:keyboard xkb_layout cz\(qwerty\)
[ { "success": true } ]
sway input type:keyboard xkb_layout us
[ { "success": true } ]

but multiple not:

sway input type:keyboard xkb_layout cz\(qwerty\),us
[ { "success": true }, { "success": false, "parse_error": true, "error": "Unknown\/invalid command 'us'" } ]

Sorry for my English...

Offline

#7 2023-10-16 12:11:50

scippio
Member
Registered: 2007-01-02
Posts: 74

Re: Swaywm problem with multiple keyboard layouts

scippio wrote:

I have very similar problem after upgrade now sad

One layout works ok:

sway input type:keyboard xkb_layout cz\(qwerty\)
[ { "success": true } ]
sway input type:keyboard xkb_layout us
[ { "success": true } ]

but multiple not:

sway input type:keyboard xkb_layout cz\(qwerty\),us
[ { "success": true }, { "success": false, "parse_error": true, "error": "Unknown\/invalid command 'us'" } ]

I tried this because my configuration stop working after update:

input * {
	xkb_layout "cz(qwerty),us"
	xkb_options "grp:ctrl_shift_toggle"
	xkb_switch_layout "next"
}

Nothing in the xkb_layout option works ... I have always english layout...

Last edited by scippio (2023-10-16 12:26:45)


Sorry for my English...

Offline

#8 2023-10-16 12:33:07

scippio
Member
Registered: 2007-01-02
Posts: 74

Re: Swaywm problem with multiple keyboard layouts

I found the problem... I commented out this last line in my sway config: "#include /etc/sway/config.d/*" and everything starts worked

EDIT: specifically this file is problem: 95-system-keyboard-config.conf

Last edited by scippio (2023-10-16 12:37:51)


Sorry for my English...

Offline

Board footer

Powered by FluxBB