9

The title says it all: I'm interested to mimic the Windows behavior, where Left Ctrl + Left Alt acts as a 3rd level chooser. This is relatively important to me, because, as a programmer, on my keyboard layout, important symbols such as {,[,] or } are accessible only by pressing Right Alt + Key, which is extremely uncomfortable using only one hand. At the moment, I use both Alt keys as a level 3 chooser, but this has some unwanted consequences, as I am no longer able to input some shortcuts(e.g. Home in Firefox).

I am on openSuse 13.1, using XFCE as a desktop environment. This question has already been asked a couple of times, but unfortunately no answer was provided in any of them, and the documentation on xkb is pretty scarce.

NonlinearFruit
  • 886
  • 9
  • 16
Vlad
  • 101
  • 1
  • 4
  • 1
    Have you found a solution for this by now? I would be very interested in this. – Dave Jan 12 '15 at 23:31
  • Unfortunately not. – Vlad Jun 05 '15 at 08:01
  • 1
    Possible duplicate of [Using both Ctrl+Alt to replace AltGr 3rd level function on xorg](http://superuser.com/questions/384334/using-both-ctrlalt-to-replace-altgr-3rd-level-function-on-xorg) – Burgi Mar 21 '16 at 08:51
  • As I still see questions for this in several forums. For me this (http://unix.stackexchange.com/questions/157834/how-to-bind-altgr-to-ctrl-alt) solution worked. – Dave Jan 20 '17 at 22:09

1 Answers1

0

The following solution is barbaric, but it works (provided you're satisfied with a Level3 Latch instead of a Level3 Shift — the difference is that with the latter all the keys have to be pressed at the same time, while with the former you first press LeftCtrl+LeftAlt, release this and only then press the key to be shifted) and does not require root.

setxkbmap -option grp:lctrl_lalt_toggle

xmodmap -e 'keycode  37 = Control_L ISO_Level3_Latch'
xmodmap -e 'keycode  64 = Alt_L ISO_Level3_Latch'

Explanation for how this works:

The xkb grp:lctrl_lalt_toggle option makes LeftCtrl shift LeftAlt to level2 and vice-versa (see: /usr/share/X11/xkb/symbols/group). It also makes the level2 shift of LeftCtrl and LeftAlt to be ISO_Next_Group, which is undesirable, since we want this to be ISO_Level3_Latch, hence we use xmodmap to change the level2 to ISO_Level3_Latch for both LeftCtrl and LeftAlt (while keeping level1 as Control_L and Alt_L). The keycodes (37 and 64) can be found either by inspecting the output of xmodmap -pke or by using xev.

If we only applied the xmodmap redefinitions (without using setxkbmap first) then the key responsible for the level2 shift would be Shift, as it is for almost all keys, so both Shift+LeftCtrl and Shift+LeftAlt (but not LeftCtrl+LeftAlt) would become Level3 Latches.

Why do we have to use a Level3 Latch rather than a Level3 Shift?

If you were to use ISO_Level3_Shift rather than ISO_Level3_Latch, you you would have to simultaneously press LeftCtrl+LeftAlt+YourDesiredKey, for the level3 shift to occur. Unfortunately, LeftCtrl and LeftAlt still remain modifiers, so apart from YourDesiredKey being correctly shifted, it would also be "modified" by one of Alt or Ctrl (depending on which you pressed first). With the latch, you don't have this problem.

aplaice
  • 364
  • 3
  • 7
  • I tried this, but for me nothing happened. I still can not use lctrl + lalt as a third level chooser. Do you have an hints on how to debug this? Either anyway, it's great thta people are still responding and working on this such a long time after the question was asked. – Dave Jan 20 '17 at 10:51
  • To check whether setxkbmap is correctly setting the relevant option, use: `setxkmap -print` and check whether the `xkb_symbols` line contains something of the sort of `+group(lctrl_lalt_toggle)`. – aplaice Jan 21 '17 at 18:14
  • You can use `xmodmap -pke` to print your current keyboard layout and you can do this both before and after the changes to ensure that they're actually being correctly applied. Finally `xev` will tell you what keycodes are being sent when you press a given key (or combination of keys) — the third line for a given keypress is most relevant. When you've applied the changes (the `setxkbmap -option ...` and the two xmodmap hacks), and you press Ctrl+Alt through xev, the output should contain ISO_Level3_Latch. – aplaice Jan 21 '17 at 18:30
  • Also, you need to ensure that the keycodes for Ctrl and Alt are actually 37 and 64, respectively (use `xev ` or `xmodmap -pke` as described above) and that you're on X11 not Wayland (since Wayland does not use xmodmap). – aplaice Jan 21 '17 at 18:35