1

I'm a vim/nvim user, and xcape has become for me a key feature in the last years.
I use it in combination with gnome-tweaks (new package name, on previous version was gnome-tweak-tool) in order to:

  • use CapsLock as a Ctrl in combination with another key
  • use CapsLock as an Esc when i use it alone.

The xcape command that I use is:

xcape -e 'Caps_Lock=Escape'

after I moved from Ubuntu 20.04 to Ubuntu 22.04 this command is not working anymore as expected.

When I run xcape -d I noticed that:

  • Ubuntu 20.04 every key event is intercepted no matter in which windows i am.
  • Ubuntu 22.04 key event from terminal/Text editor/Files is not intercepted, but when I'm on Chrome they are.

Does anyone knows the reason of this behavior? It is very annoying!

Thank you in advance for the help!

Edit:
The answer of @vanadium helped me to get xcape -d to work again.
Unfortunately the autostart service that I used is not working anymore:

[Desktop Entry]
Type=Application
Exec=xcape -e 'Caps_Lock=Escape'
Name=Keyboard Setup
Comment=Custom keyboard setup

After some researches and tries I finally got it to work just updating the entry in this way:

[Desktop Entry]
Type=Application
Exec=xcape -d
Terminal=false
Name=Keyboard Setup
Comment=Custom keyboard setup
X-GNOME-Autostart-enabled=true

In the beginning I tried to fork the process with nohup xcape -d & and create a system service with not much success.

1 Answers1

1

The reason of this behaviour will be that you are now running Wayland instead of Xorg. Both users that do a fresh install and users that upgrade will be moved to Wayland.

Wayland implements security measures to the extend of breaking features. One of these is that programs cannot anymore intercept keystrokes.

Terminal/Text editor/Files are native Wayland programs. Google Chrome, however, runs on xwayland, an emulation layer in Wayland that allows to run programs that require Xorg. xcape will work in all programs that run on xWayland.

There are two possibilities:

  1. Move to Xorg: Log out, click the cog wheel to change to the session Ubuntu on Xorg before entering your password, then log in.

  2. Stay on Wayland and achieve an effect that comes rather close to what you had with xcape: in GNOME Tweaks, head to the Keyboard & Mouse tab. In Additional Layout Options there is an option to make CapsLock an additional Ctrl:

    Additional Layout Options window with Caps Lock as Ctrl highlighted

    You then only lose the possibility to use that key stand alone as Esc.

vanadium
  • 97,564