3

Under X, I can make Caps Lock behave as Esc when pressed briefly, but as Ctrl when held down with:

setxkbmap -option 'caps:ctrl_modifier'
xcape -e 'Caps_Lock=Escape' -t 100

How can I replicate this behavior under Sway / Wayland?

Alexander
  • 9,607
  • 3
  • 40
  • 59

1 Answers1

7

Put the following in your sway config:

input "type:keyboard" {
    xkb_options caps:ctrl_modifier
}

Source: https://github.com/swaywm/sway/wiki#keyboard-layout

UPDATE: the OP asks for "Caps lock is an Escape but is a Control when held". Turns out there is a simple program that does exactly that at libevdev level (so works with any display server, Wayland or not, and the sway config above is not needed).

A related discussion thread: https://github.com/swaywm/sway/issues/719

  • Thanks, this helps for making Caps Lock behave as Ctrl, but it only answers half the question. I also want Caps Lock to behave like Escape when it is pressed briefly. It could be that Sway just can't do this yet. – Alexander Jun 21 '19 at 08:46
  • 1
    @Alexander updated my answer. Sway doesn't do that but there is another tool that does exactly that. – Tony Beta Lambda Jun 21 '19 at 09:40
  • 3
    You can use `type:keyboard` as ``. – Dzintars Jun 24 '21 at 21:39