3

I'm using a MacBook with Croatian layout. Common PC Croatian layout (on Windows and in Linux) uses combinations with AltGr to get various symbols, such as...

  • AltGr+V for @
  • AltGr+F for [
  • AltGr+B for {

On OS X, this is replaced with..

  • Alt+Shift+2 for @
  • Alt+Š for [
  • Alt+Shift+Š for {

-- that is, US layout positions + alt provide the required symbol.

When I'm working with Linux, I find it hard to switch back to Croatian PC mapping. Hence, I tend to use US layout the most (and then I have the problem of being unable to type local symbols such as ČĆŽŠĐ, plus the problem of having to NOT type Alt for @, [, {, etc.)

Keyboard mapping definitions, located in Ubuntu in /usr/share/X11/xkb, provide an easy way to remap symbols on keydown, shift+keydown , altgr+keydown and altgr+shift+keydown . I couldn't find a way to map things to alt+keydown and alt+shift+keydown .

How can I map glyphs to alt+keydown and alt+shift+keydown in X11?

2 Answers 2

1

Well, I have a silly idea: you could hack it together with xdotool and xbindkeys:

add the following to your ~/.xbindkeysrc

"xdotool key at"
    Shift+Alt+Mod2 + 2

Taadaa!

(Alright, bring on the downvotes!)

1
  • Sorry for the "long" delay in accepting the answer (now there's an understatement!) - but I never got around to trying it until now. Unfortunately, this doesn't seem to work for me under Ubuntu 12.04; even trying Shift+Alt + 2 as suggested by xbindkeys -mk and the GUI xbindkeys-config doesn't help. Does this work for you? I nonetheless accepted the answer because it's on the right track. Jul 19, 2012 at 17:14
3

You can not configure it, because Alt is not a key code modifier in standard X servers. In X11 keys can be defined and changed with xmodmap. The program xev can be used to identify the key code. Start xev and press 2. On a German PC keyboard it looks this way:

KeyPress event, serial 33, synthetic NO, window 0x3000001,
    root 0x69, subw 0x0, time 3044226, (160,148), root:(164,198),
    state 0x0, keycode 11 (keysym 0x32, 2), same_screen YES,
    XLookupString gives 1 bytes: (32) "2"
    XmbLookupString gives 1 bytes: (32) "2"
    XFilterEvent returns: True

KeyRelease event, serial 33, synthetic NO, window 0x3000001,
    root 0x69, subw 0x0, time 3044305, (160,148), root:(164,198),
    state 0x0, keycode 11 (keysym 0x32, 2), same_screen YES,
    XLookupString gives 1 bytes: (32) "2"
    XFilterEvent returns: False

You can see that the key code for the key is 11. Now you can display the key code definition with xmodmap:

$ xmodmap -pke|grep ' 11 ='
keycode  11 = 2 quotedbl twosuperior oneeighth twosuperior oneeighth

You can see four different keys the key code 11 can generate. The man page for xmodmap explains which key gets generated by which modifier:

    keycode NUMBER = KEYSYMNAME ...
           The list of keysyms is assigned to the indicated keycode (which
           may be specified in decimal, hex or octal and can be determined
           by running the xev  program).   Up  to  eight  keysyms  may  be
           attached  to  a  key, however the last four are not used in any
           major X server implementation.  The first keysym is  used  when
           no  modifier  key  is pressed in conjunction with this key, the
           second with Shift, the third when the Mode_switch key  is  used
           with  this  key  and  the  fourth when both the Mode_switch and
           Shift keys are used.

Only Shift and Mode_switch are valid modifiers for X11 key codes. If you want your Alt key to be a valid modifier you have to patch your X server. Theoretically it is possible, because there are 8 modifiers possible. But your X server must know that.

1
  • While you did provide me an explanation, I'm only upvoting you and accepting the other answer, which actually provided the solution. Thanks nonetheless :) Jul 19, 2012 at 16:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .