Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add the ability to change keyboard layout while sway is running #1242

Closed
vikstrous opened this issue Jun 18, 2017 · 11 comments
Closed

add the ability to change keyboard layout while sway is running #1242

vikstrous opened this issue Jun 18, 2017 · 11 comments

Comments

@vikstrous
Copy link

As far as I can tell, right now the only way to change the keyboard layout is to restart sway. It would be nice if there was a way to change it through swaymsg.

@Timidger
Copy link
Member

This has been discussed before, and currently is not possible. It might become an option once sway migrates to wlroot.

@ddevault
Copy link
Member

Use something to this effect.

export XKB_DEFAULT_LAYOUT=de,us
export XKB_DEFAULT_OPTIONS=grp:alt_shift_toggle
sway

Read the XKB manual.

@tjaartvdwalt
Copy link

I use a very customized keyboard layout, and being able to change the keyboard layout at run time would be very handy in a couple of situations:

  • A colleague wants to type on my laptop
  • I want to plug in an external keyboard that has a different layout

Are there plans to support this with wlroots? Is there a way I can contribute?

@ddevault
Copy link
Member

The plan is to support this in wlroots. The best place to help out wouldn't be keyboard related, but on wlroots as a whole (because sway won't switch until every feature is done, so it won't benefit from the features you want until then).

To help, pick something to do from here: swaywm/wlroots#9

We collaborate over IRC in #sway on freenode, be there.

@toger5
Copy link

toger5 commented Nov 20, 2019

This is now also pissible with the sway configuration. It took me some time to figure it out thats why I am posting it here:

xkb-Layout us,de
xkb_options grp:win_space_toggle

(it is documented in the sway input man page: https://jlk.fjfi.cvut.cz/arch/manpages/man/sway-input.5)

Possible switches:

Option Description
grp:switch Right Alt (while pressed)
grp:lswitch Left Alt (while pressed)
grp:lwin_switch Left Win (while pressed)
grp:rwin_switch Right Win (while pressed)
grp:win_switch Any Win (while pressed)
grp:menu_switch Menu (while pressed), Shift+Menu for Menu
grp:caps_switch Caps Lock (while pressed), Alt+Caps Lock for the original Caps Lock action
grp:rctrl_switch Right Ctrl (while pressed)
grp:toggle Right Alt
grp:lalt_toggle Left Alt
grp:caps_toggle Caps Lock
grp:shift_caps_toggle Shift+Caps Lock
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:alt_caps_toggle Alt+Caps Lock
grp:shifts_toggle Both Shift together
grp:alts_toggle Both Alt together
grp:ctrls_toggle Both Ctrl together
grp:ctrl_shift_toggle Ctrl+Shift
grp:lctrl_lshift_toggle Left Ctrl+Left Shift
grp:rctrl_rshift_toggle Right Ctrl+Right Shift
grp:ctrl_alt_toggle Alt+Ctrl
grp:alt_shift_toggle Alt+Shift
grp:lalt_lshift_toggle Left Alt+Left Shift
grp:alt_space_toggle Alt+Space
grp:menu_toggle Menu
grp:lwin_toggle Left Win
grp:win_space_toggle Win+Space
grp:rwin_toggle Right Win
grp:lshift_toggle Left Shift
grp:rshift_toggle Right Shift
grp:lctrl_toggle Left Ctrl
grp:rctrl_toggle Right Ctrl
grp:sclk_toggle Scroll Lock
grp:lctrl_lwin_rctrl_menu Left Ctrl+Left Win to first layout; Right Ctrl+Menu to second layout
grp:lctrl_lwin_toggle Left Ctrl+Left Win

source: https://jlk.fjfi.cvut.cz/arch/manpages/man/xkeyboard-config.7

@aviau
Copy link

aviau commented Feb 10, 2020

Is it now possible to change keyboard layouts with swaymsg? I am not happy with the proposed toggles here and I'd like to use bindsym instead.

@maxmouchet
Copy link

This is now also pissible with the sway configuration. It took me some time to figure it out thats why I am posting it here:

xkb-Layout us,de
xkb_options grp:win_space_toggle

It should be xkb_layout instead of xkb-Layout.

Also, to set the variant for each layout:

# Switch between US (international) and US (default).
xkb_layout us,us
xkb_variant intl,
xkb_options grp:win_space_toggle

See https://unix.stackexchange.com/questions/197595/setxkbmap-multiple-layouts-with-different-variants.

@deifactor
Copy link

Is it now possible to change keyboard layouts with swaymsg? I am not happy with the proposed toggles here and I'd like to use bindsym instead.

Yes, you can do this. It's a bit wonky, I noticed I had to explicitly set xkb_layout us before xkb_variant colemak would take any effect. but it does work.

@chesedo
Copy link

chesedo commented Jul 26, 2021

I noticed I had to explicitly set xkb_layout us before xkb_variant colemak would take any effect. but it does work.

With the latest update /etc/sway/definitions and /etc/sway/inputs/* went missing for me. This broke my colemak variant, but setting xkb_layout us fixed it too

@emersion
Copy link
Member

We never shipped these files. Maybe they were shipped by your distribution.

@chesedo
Copy link

chesedo commented Jul 26, 2021

Okay, I just filled a bug with my distribution at manjaro-sway/manjaro-sway#112

Is the xkb_variant not working unless xkb_layout is also set a bug though? (Which I can create a separate issue for)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

10 participants