rvaiya / keyd

A key remapping daemon for linux.
MIT License
3k stars 175 forks source link

Keyboard layouts with umlauts #805

Open flenzen opened 3 months ago

flenzen commented 3 months ago

This seems to be related to #470, but I cannot tell if this is the same problem. Feel free to close/merge if it is.

I want to be able to alter between us and de layout. For that, I copied de from /usr/share/keyd/layouts/ to /usr/share/keyd/ and produced the following config file:

# Note: layouts and layout switching is currently handled by setxkbmap (in i3 config), because I cannot get it to work here.
[ids]
*

include de

[main]
# Assign new layer (named capslock, see below) to capslock when held, and escape when pressed. Capslock functionality on both shifts.
capslock = overload(capslock, escape)

# Make both shifts toggle capslock
[shift]
leftshift = capslock
rightshift = capslock

# Capslock behaves as Shift-Alt-Ctrl-Win, except for hjkl (vim-style navigation)
[capslock]
d = setlayout(de)

Switching layout works, but umlauts produce strange number sequences. keyd monitor -t reports those as

+111 ms keyd virtual keyboard   0fac:0ade:efba1ddf  cancel down
+0 ms   keyd virtual keyboard   0fac:0ade:efba1ddf  cancel up
+0 ms   keyd virtual keyboard   0fac:0ade:efba1ddf  0 down
+0 ms   keyd virtual keyboard   0fac:0ade:efba1ddf  0 up
+0 ms   keyd virtual keyboard   0fac:0ade:efba1ddf  2 down
+0 ms   keyd virtual keyboard   0fac:0ade:efba1ddf  2 up
+0 ms   keyd virtual keyboard   0fac:0ade:efba1ddf  n down
+0 ms   keyd virtual keyboard   0fac:0ade:efba1ddf  n up

xev reports the same. Apparently, these are supposed to be handled as compose sequences, which does not work. My ~/.XCompose is

<Multi_key> + <Z> + <Z> : "ℤ" # Blackboard bold Z (set of integers)
include "/usr/share/keyd/keyd.compose"

The first line is there to make sure that the file is actually parsed. Multi_key is set to menu using setxkbmap after starting keyd. Indeed, I can verify that this does not work in applications that otherwise process compose sequences correctly (I tried, e.g., xed).

For now, my workaround is

[capslock]
d = command(setxkbmap -layout "de")
u = command(setxkbmap -layout "us")

which seems to work, as far as I can tell at the moment.

I am running keyd v2.5.0.

In any case, thank you very much for this piece of software!!

P.S.: How do I switch back to no/default/... layout?