Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make Alt_R an Alt (A-) modifier key (instead of a Meta (M-) modifier key)

Tags:

emacs

x11

xmodmap

I want to set Alt_L as META (ie. M- in emacs) but Alt_R as ALT. How do I modify .Xmodmap and/or .emacs to achieve this?

like image 490
wdkrnls Avatar asked Apr 08 '12 03:04

wdkrnls


2 Answers

Below is my .Xmodmap. It doesn't exactly implement your specification, but should give you an idea how to achieve it. Only Sec-2 should need modification in your case; assuming your keyboard is similar to mine, you will only need 1 line in this section: keycode 108 = Alt_R, since Alt_L is already recognized as Meta_L by the X-server.

Here is my .Xmodmap which makes all modifiers recognized by Emacs available (Alt, Meta, Super, Hyper, Control, Shift):

!!! Implement the following layout:
!!!     Alt  A S D F ...
!!!     Shift Z     X    C V B N M ...
!!!     Hyper Super Meta --Space-- Control Super Hyper

!!! by transforming from the conventional layout:
!!!     Caps:66
!!!     Shift
!!!     Ctrl:37 Win:133 Alt:64 Space AltGr:108 Menu:135 Ctrl:105

!! Sec-1.
clear Control
clear Lock
clear mod1
clear mod2
clear mod3
clear mod4
clear mod5

!! Sec-2. System dependent; use xev to find the exact keycodes:
keycode  37 = Hyper_L
keycode  64 = Meta_L
keycode  66 = Alt_L
keycode 105 = Hyper_R
keycode 108 = Control_R
keycode 135 = Super_R

!! Sec-3.
add Control = Control_L Control_R
add mod1 = Meta_L Meta_R
add mod2 = Hyper_L Hyper_R
add mod3 = Num_Lock
add mod4 = Alt_L Alt_R Multi_key
add mod5 = Super_L Super_R Mode_switch
like image 61
huaiyuan Avatar answered Oct 20 '22 18:10

huaiyuan


Here is my current .xmodmaprc, it may use some work but ilustrates how you would go along changing specific keys with different modifiers (using the ksysym keyword). I dismiss the cedilla (Spanish keyboard) and place a slash / backslash there, among other things.

pointer = 3 2 1 4 5 6 7 8 9 10

clear Mod4
remove Lock = Caps_Lock
remove Control = Control_L
remove Mod5 = ISO_Level3_Shift

keysym ccedilla = slash backslash NoSymbol NoSymbol braceright
keysym 3 = 3 numbersign NoSymbol NoSymbol periodcentered
keysym 1 = 1 exclam NoSymbol NoSymbol masculine

keysym 0xba = bar
! the next one is neccesary becuase the above command
! modifies the m key too!
keysym 0x6d = m

keysym Control_L = Super_L
keysym Caps_Lock = Control_L
keysym ISO_Level3_Shift = Hyper_L
keysym Super_L = ISO_Level3_Shift

add Lock = Caps_Lock
add Control = Control_L
add Mod4 = Super_L
add Mod4 = Super_R
add Mod3 = Hyper_L
add Mod3 = Hyper_R
add Mod5 = ISO_Level3_Shift
like image 37
Leockard Avatar answered Oct 20 '22 18:10

Leockard