3

Is it possible to set modifier only to left alt?

I need to write special characters using right alt (or alt gr), therefore I would like not to have right alt bound to i3wm shortcuts.

I've set mod using:

set $mod Mod1

Currently, both(left and right) alt keys are used as modifier by i3wm.

Output of xmodmap -pm:

xmodmap:  up to 4 keys per modifier, (keycodes in parentheses):

shift       Shift_L (0x32),  Shift_R (0x3e)
lock        Caps_Lock (0x42)
control     Control_L (0x25),  Control_R (0x69)
mod1        Alt_L (0x40),  Alt_R (0x6c),  Meta_L (0xcd)
mod2        Num_Lock (0x4d)
mod3      
mod4        Super_L (0x85),  Super_R (0x86),  Super_L (0xce),  Hyper_L (0xcf)
mod5        ISO_Level3_Shift (0x5c),  Mode_switch (0xcb)
3
  • Sounds like you probably want to use xmodmap.
    – Tom Hunt
    Commented Sep 21, 2015 at 20:12
  • How did you configure your keyboard layout? What's the output of xmodmap -pm? Commented Sep 21, 2015 at 23:11
  • @Gilles I've added output of xmodmap -pm. It looks like mod1 is configured for both alt keys. Unfortunately, I've got no experience with xmodmap, yet.
    – kravemir
    Commented Sep 22, 2015 at 5:44

1 Answer 1

3

You have the right Alt key (keycode 0x6c) configured so send the mod1 modifier, same as the left Alt key. The right Alt key sends the Alt_R keysym. That means your right Alt key is an Alt key, not an AltGr key. In order to make the key an AltGr key, you need to both make it send the Mode_switch keysym and a separate modifier. (If the keysym assignments and the modifier assignment are inconsistent, some applications will use one setting, some will use the other, and some will just behave strangely.)

Put these lines in ~/.Xmodmap and arrange to run xmodmap ~/.Xmodmap when you log in. I'm not sure about the effect of ISO_Level3_Shift (used for switching between layouts) being assigned to the same modifier; if that turns out to be a problem, put that and Mod_switch on different modifiers.

keycode 108 = Mode_switch
add Mod5 = Mode_switch

If you change modifier assignments during a session, a few applications need to be restarted; I don't know if that's the case for i3wm.

3
  • Well, you've pointed me to right direction, but this configuration worked for me: clear mod1 \n keycode 0x6c = ISO_Level3_Shift NoSymbol ISO_Level3_Shift NoSymbol \n add Mod1 = Alt_L \n add Mod5 = ISO_Level3_Shift
    – kravemir
    Commented Sep 22, 2015 at 9:29
  • Actually effect of ISO_Level3_Shift is what AltGr should do, not the Mode_switch. Please correct the answer, and I'll accept it ;-)
    – kravemir
    Commented Sep 22, 2015 at 9:34
  • @Miro Mode_switch is what AltGr sends when you configure the keyboard with xmodmap. If ISO_Level3_Shift works for you, you must be using XKB to set the layout, and in that case you should use the appropriate XKB option to make Alt_R be AltGr. I think you need to add level3(ralt_switch) to your symbols, e.g. xsetxkbmap 'pc+inet(evdev)+fr+level3(ralt_switch)' (replace fr by the code for your language's layout). Commented Sep 22, 2015 at 11:38

You must log in to answer this question.

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