Looking for alternative for setxkbmap in wayland

I like vim, and l like to swap the function of the escape and caps lock keys using the following command:

setxkbmap -option "caps:swapescape"

This command works in Fedora 30 Workstation where I’m running xorg because of a series of xrandr commands that I use to fix the display of an external monitor hooked to a laptop. In my new install of Fedora 31 Workstation Beta this command does nothing. I’m guessing it is because Wayland is the default for the Gnome session on that fresh install.

Does Wayland have an alternative way to accomplish the same goal that I’m trying to achieve with the setxkbmap command?

Since all my other Linux boxes, and even my Windows 10 box has the function of the esc and caps lock swapped it would be hard to just learn a different shortcut to accomplish a similar functionality. So don’t suggest alternative vim shortcuts, I know about that possible solution. I just really like having caps lock remapped as esc and esc mapped as caps lock.

If you are on Gnome you may try this:

dconf write /org/gnome/desktop/input-sources/xkb-options "['caps:swapescape']"
3 Likes

Thank you @ludwigd. That did the trick. I will admit honestly, that I had read something about xkb-options and wayland as being the new way, but I didn’t find any way to interact with the settings. I’m not exactly sure what I did with the “dconf” command since there is no “/org/gnome/…” directory structure in the root directory. I will have to do some reading on what I actually did with this command that I trusted to just type into the terminal and run. I figured it looked pretty harmless since it uses the same option as “setxkbmap”. What a great community, and thank you so much for the quick answer. It took me longer to get home and run the command on my system and test the result than the amount time I waited for an answer to my issue. Have a great day!

2 Likes

From my understanding gnome has some sort of settings database – something akin to windows registry if you like, but much-much less complex/confusing and more comprehensible.

You can read/set it with gui program dconf-editor and cli ones gsettings or dconf.

Here’s some bits of explanation: https://wiki.gnome.org/Projects/dconf

And here’s a much more detailed and comprehensive guide:

2 Likes

Thank you @nightromantic for the links to documentation. I appreciate the opportunity to learn more so that I can make the most of my Gnome on Wayland experience.

You’re welcome )

Also I sometimes find it easier just to look at things ) You can install dconf-editor with

sudo dnf install dconf-editor

and just browse through some settings (without changing anything) – it’s enougth for basic understanding of this gnome feature. )