Fedora – Keyboard Layout with Sway on Fedora (Wayland)

fedorakeyboard-layoutswaywayland

I have recently installed Fedora 27 which I find quite nice, I like the Gnome Desktop, but for working I definitely prefer a tiling window manager. I would like to use Sway because I was using i3 before and now that Gnome uses wayland I would like to make the change.

I have a french azerty keyboard which is well configured in Gnome, but Sway uses an U.S. layout. I don't know how I can make the change permanently, I can make a script for changing layout each time Sway run but I find this an ugly solution… Is there any proper way to do it so Sway can use the proper keyboard layout?

Thank you

PS: I read that post but it did not help me, probably because I do not have enough knowledge regarding X.

Best Answer

In the current release, sway only loads XKB layouts from environment variables at execution time (XKB_DEFAULT_LAYOUT, XKB_DEFAULT_VARIANT, XKB_DEFAULT_OPTIONS). Wayland does not provide a server like X, so each Wayland compositor has to implement its own method for setting or changing layouts -- generic tools like setxkbmap are out unless/until a protocol is defined/adopted that will allow the tool to talk to any compositor.

Eventually, sway will add the ability to change layouts during runtime. This pull request adds swaymsg input subcommands to set XKB options at runtime; it's presently in the development branch (wlroots). If it is released as in that PR, you'd be able to issue commands like these to change the keyboard:

swaymsg input 0:0:X11_keyboard xkb_layout de