3

I use an alternative german keyboard layout on Ubuntu 18.04:

~$ setxkbmap de koy

Now I want to swap three keys (Mod3 → f → ß → Mod3) as shown in that picture: swap three keys

This are the keycodes for these keys:

~$ xmodmap -pke | grep -E 'keycode  (33|48|51)'
keycode  33 = ssharp U1E9E ssharp U1E9E ampersand Greek_finalsmallsigma KP_Add KP_Add jot NoSymbol ampersand Greek_finalsmallsigma KP_Add KP_Add jot
keycode  48 = f F f F at Greek_phi period KP_Decimal Greek_PHI NoSymbol at Greek_phi period KP_Decimal Greek_PHI
keycode  51 = ISO_Level3_Shift NoSymbol ISO_Level3_Shift

Q1: Why are there 15 columns for the f key and the ß key? /usr/share/X11/xkb/symbols/de only defines 8 columns!

I can swap the keys by using these xmodmap commands:

~$ xmodmap -e "keycode  51 = ssharp U1E9E ssharp U1E9E ampersand Greek_finalsmallsigma KP_Add KP_Add jot NoSymbol ampersand Greek_finalsmallsigma KP_Add KP_Add jot"
~$ xmodmap -e "keycode  33 = f F f F at Greek_phi period KP_Decimal Greek_PHI NoSymbol at Greek_phi period KP_Decimal Greek_PHI"
~$ xmodmap -e "keycode  48 = ISO_Level3_Shift NoSymbol ISO_Level3_Shift"

Now the keys are swapped but …

  • the ß (ssharp) key returns ß on all levels! Expected (as before swapping): ß ẞ & + ς ∘
  • key 48 (former f key) works as Mod3 except when used together with other modifiers: Shift+Mod3+a should give an α but gives an A now.

Just checking again:

~$ xmodmap -pke | grep -E 'keycode  (33|48|51)'
keycode  33 = f F f F ampersand Greek_phi KP_Add KP_Add Greek_PHI NoSymbol ampersand Greek_phi KP_Add KP_Add Greek_PHI NoSymbol f F ampersand Greek_phi KP_Add KP_Add Greek_PHI NoSymbol f F ampersand Greek_phi KP_Add KP_Add Greek_PHI
keycode  48 = ISO_Level3_Shift NoSymbol ISO_Level3_Shift NoSymbol NoSymbol NoSymbol NoSymbol NoSymbol NoSymbol NoSymbol NoSymbol NoSymbol NoSymbol NoSymbol NoSymbol NoSymbol ISO_Level3_Shift NoSymbol NoSymbol NoSymbol NoSymbol NoSymbol NoSymbol NoSymbol ISO_Level3_Shift
keycode  51 = ssharp NoSymbol ssharp U1E9E at Greek_finalsmallsigma period KP_Decimal

keycodes 48 and 51 are not as I set them.

Q2: What did go wrong?

In some other questions on StackExchange people say that it's important to remove or clear modifiers before changing them. But this always fails:

~$ xmodmap -pm
xmodmap:  up to 3 keys per modifier, (keycodes in parentheses):

shift       Shift_L (0x32),  Shift_R (0x3e)
lock        Shift_L (0x32)
control     Control_L (0x25),  Control_R (0x69)
mod1        Alt_L (0x40),  Meta_L (0xcd)
mod2        BadKey (0xcf)
mod3        ISO_Level5_Shift (0xcb)
mod4        Super_L (0x85),  Super_R (0x86),  Super_L (0xce)
mod5        ISO_Level3_Shift (0x5c)

~$ xmodmap -e "remove mod5 = ISO_Level3_Shift"
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  118 (X_SetModifierMapping)
  Value in failed request:  0x17
  Serial number of failed request:  11
  Current serial number in output stream:  11

~$ xmodmap -e "clear mod5"
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  118 (X_SetModifierMapping)
  Value in failed request:  0x17
  Serial number of failed request:  8
  Current serial number in output stream:  8

Q3: What do these errors mean?

1
  • Q2 is definitely because you didn't clear the modifier. See unix.stackexchange.com/q/195065 and unix.stackexchange.com/q/103814 for some similar problems. I'm not sure about Q3, but I suspect that it's because of that Mod2 BadKey bit. Even when you're just changing one thing, the xmodmap utility calls XGetModifierMapping, makes that one change, then calls XSetModifierMapping. If you've somehow ended up with a bad configuration on the server, the Set step fails. clear mod2 may help, although I'm not sure if that's enough. Commented Nov 19, 2024 at 22:13

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.