#989707 sway: should inherit xkb_model and xkb_layout from /etc/default/keyboard

Package:
sway
Source:
sway
Description:
i3-compatible Wayland compositor
Submitter:
Sean Whitton
Date:
2025-12-18 14:19:28 UTC
Severity:
normal
Tags:
#989707#5
Date:
2021-06-11 00:35:25 UTC
From:
To:
Hello,

Currently one has to add lines like this to one's sway config:

    input type:keyboard xkb_model "pc105"
    input type:keyboard xkb_layout "us+spw(emacs)"

but I already have these values configured in /etc/default/keyboard.

I think that something should be added to /etc/sway/config.d which
causes sway to respect the values in /etc/default/keyboard, as that's
the standard way to set keyboard configuration on Debian.

Thanks!

#989707#10
Date:
2025-12-18 14:04:36 UTC
From:
To:
found 989707 1.10.1-2
tags 989707 + patch
user luca@pca.it
usertag 989707 + pca.it-installation
thanks

Hi there,
[...]

Exactly five versions later (and also 11 years later...) and I moved
from i3 to sway since Debian 13/trixie defaults to Wayland, just to
discover that my keyboard configuration is broken.
13/trixie sway session which RESPECTS my choices:

- /etc/sway/config.d/20keyboard-configuration.conf:
  ```
  # set the default keyboard according to '/etc/default/keyboard-configuration'
  # <https://bugs.debian.org/989707>
  # <https://github.com/swaywm/sway/issues/6687>
  # <https://github.com/swaywm/sway/issues/3846>
  #  <https://bugs.debian.org/924063>

  exec /path/to/sway-set-keyboard-configuration.sh
  ```

- /path/to/sway-set-keyboard-configuration.sh:
  ```
  #!/bin/sh
  #
  # <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=989707#5>

  grep -e '^XKB[A-Z]*=' /etc/default/keyboard 2>/dev/null | \
   cut -c 4- | \
   tr '[[:upper:]]' '[[:lower:]]' | \
   while IFS= read -r LINE; do
       swaymsg "input type:keyboard xkb_${LINE%=*} ${LINE#*=}"
   done
  ```

My ~/.config/sway/config starts with:
```
# Default config for sway
#
# Copy this to ~/.config/sway/config and edit it to your liking.
#
# Read `man 5 sway` for a complete reference.

#### ATTENTION, first include everything else, then override!
include /etc/sway/config-vars.d/*
##### ATTENTION, needed for {WAYLAND_,}DISPLAY & Co., plus '/etc/default/keyboard'
include /etc/sway/config.d/*


### Variables
#
# Logo key. Use Mod1 for Alt.
set $mod Mod4
[...]
```

Thx, bye,
Gismo / Luca