Keyboard Layout with Sway on Fedora (Wayland)

16,113

Solution 1

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.

Solution 2

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
Share:
16,113

Related videos on Youtube

Nicolas Scotto Di Perto
Author by

Nicolas Scotto Di Perto

Updated on September 18, 2022

Comments

  • Nicolas Scotto Di Perto
    Nicolas Scotto Di Perto over 1 year

    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.

  • Nicolas Scotto Di Perto
    Nicolas Scotto Di Perto about 6 years
    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.