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.

3 Answers 3


In newer versions of sway you can simple put the following lines in your config file:

input * xkb_layout "de" # German keyboard layout
input * xkb_options "caps:escape" # Make Caps Lock an additional Esc

See xkeyboard-config(7) for a list of available layouts and options and Sway#Keymap on the ArchWiki.


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
  • So that means I will not be able to use Sway properly for now? Wayland is cool but it adds a lot of works to be done by the WM. Commented Feb 20, 2018 at 15:51

To change the keyboard layout, you need to set some environment variables before launching Sway. While we wait for Sway 1.0 this is the correct way of doing it.

  • cp /usr/share/wayland-sessions/sway.desktop /usr/share/wayland-sessions/sway-custom.desktop
  • Open sway-custom.desktop and enter
    • [Desktop Entry] Name=SwayCustom Comment=SirCmpwn's Wayland window manager Exec=sway-custom Type=Application
  • Create /bin/sway-custom and enter
    • #!/bin/bash export XKB_DEFAULT_OPTIONS=caps:escape # enter your options here sway
  • chmod +x /bin/sway-custom
  • Restart your computer and choose SwayCustom from the list of window managers before logging in

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .