Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I would like to setup a compose key, but the only options available in the KDE system settings (and via /usr/share/X11/xkb/rules) are:

compose:ralt         Right Alt
compose:lwin         Left Win
compose:rwin         Right Win
compose:menu         Menu
compose:lctrl        Left Ctrl
compose:rctrl        Right Ctrl
compose:caps         Caps Lock
compose:102          Less-than/Greater-than

None of those please me though; "compose:caps" might be ok, but it's mapped to ctrl already.

Is there an option so setup some key (e.g. some of those extra function keys), or to get the key itself somehow? (e.g. ralt would be OK, if I could easily get the original behavior of the key (AltGr))

I would love to have something like Shift-AltGr to trigger Compose mode.

I guess I could add an extra rule, like it's done for/with compose:102.. what does 102 refer to? (it's not something dumped via xev).

There is also an option lv3:ralt_switch_multikey (Right Alt, Shift+Right Alt key is Multi_Key), but this did not work as expected (see http://bugs.kde.org/246472).

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

lv3:ralt_switch_multikey is what I was looking for:

# But here it is: /usr/share/X11/xkb/rules/xorg.lst
# Anyway... what this is doing:
# lvl3:ralt_switch_multikey
#   right alt = AltGr = choose third shift level
#   shift + right alt = compose key aka Multi_Key

(via http://ndim.fedorapeople.org/stuff/radeonhd/xorg.conf)

I have this set via the KDE system settings (Keyboard => Advanced), so that I have the following in my ~/.kde/share/config/kxkbrc:

Options=ctrl:nocaps,lv3:ralt_switch_multikey
share|improve this answer
    
+42 – wȯŕkß łīkə ả čhą®µ™ ;-) The best of it is that character shortcuts in my user-defined map are still working if I use AltGr+Shift (fourth shift level) instead of the less common Shift+AltGr (now Compose), and that systemsettings keeps it. –  PointedEars Dec 3 '12 at 18:38
    
You do not have to edit the configuration file. That setting is located in KDE 4.8.4 under “Keyboard” → “Advanced” → “Key for changing into the third keyboard level” → “Right Alt key, Shift + right Alt key is Multi key”. That is why it survives an update via the GUI. (I have translated the German labels, so the English ones may vary.) –  PointedEars Jan 27 '13 at 11:00
add comment

Another approach is to use xmodmap. Add the following to your ~/.Xmodmap:

keycode 134 = ISO_Level3_Shift Multi_key

This is case sensitive. The right alt key ( AltGr ) on my keyboard happens to have keycode 134. If this doesn't work, the likely explanation is that your keyboard uses a different number for that key. To find out, run xev, hit whatever key you want to use and look for the part that says "keycode XXX".

You can of course use any key for the purpose; for instance,

keycode 38 = a Multi_key

would make the a key serve as the compose key (only) when shifted. The inability to type capital As would be a clear detriment, so perhaps you want to do something else ☺

I use Shift+Shift with a trick:

keysym Shift_L = Shift_L Multi_key
keysym Shift_R = Shift_R Multi_key

This makes the left shift key act as the left shift key and the right shift key as the right shift key—except that if you hold a shift key, each shift key acts like Compose. A few scenarios to illustrate:

If you press left shift, press right shift, release right shift, and release left shift—then you get the same effect as if you had pressed a physical Compose key (old Sun keyboards had those, IIRC). So in particular:

  • ShiftShift + : + ) produces a smiley, ☺ (at least with my ~/.XCompose)
  • ShiftShift + a + a produces the å character, "å".

If press left shift, press right shift, and then release the two shift keys in the opposite order, you get the same effect as above.

If you press left shift and release it again (with no intervening right shift), you get two keyboard events:

  • a KeyPress event for Shift_L
  • a KeyRelease event for Multi_key

This is because when you release the left shift key, a shift key is being held (the left one -_-) so the key is treated as if Multi_key was all it ever did. This hasn't caused me any noticeable problems, but perhaps some old and buggy application could choke on the KeyPress vs. KeyRelease mismatch.

Note also that interaction between one-shot keys, modifier keys and state-toggle keys (e.g. a, Shift and Caps Lock) interact funnily. If you want to use the same key both as a Caps Lock key and (when shift is held) a compose key, you might get funky effects. I seem to recall that you get all applicable effects, which is probably not what you want, but feel free to try it out.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.