Ask Ubuntu Asked by Hoogendijk on November 28, 2021
I’m trying to remap my right alt to behave like my right ctrl so I can use my right thumb to press the ctrl button. This is Ubuntu 12.04.
I’ve created the file .Xmodmap in my home folder with the following content:
clear control
clear mod1
!keycode 64 = Alt_L Meta_L
keycode 108 = Alt_R Meta_R
add control = Control_L Control_R Alt_R
add mod1 = Alt_L Meta_L
As you might guess, my left alt key has keycode 64 and my left alt key has keycode 108.
This actually works in the sense that my right alt key behaves as if I press the ctrl key.
However my left alt key now doesn’t do anything anymore, which means I don’t have an alt key left. This is strange given that xmodmap
gives the following output:
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), Alt_R (0x6c)
mod1 Alt_L (0x40), Alt_L (0xcc), 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)
The strange thing is that when I remove the Alt_R mapping onto control, the alt keys work.
(ie., change the second to last line to:)
add control = Control_L Control_R
Now even my right alt behaves as an alt key which confuses me. After removing the Alt_R mapping from the control line the output of xmodmap
gives:
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_L (0xcc), 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)
Hope you guys can help.
ps. I used this website as a source.
I've found a much simpler way.
Add that command to autostart or .xinitrc:
setxkbmap -option ctrl:ralt_rctrl
It forces right alt to behave like right control. I also recommend to check out other setxkbmap options, there are some useful ones.
Answered by Vladislav Pechkin on November 28, 2021
On Ubuntu 19.04, To make the mapping system-wide, you should change two files:
Add the following section to the former one:
// Ctrl is mapped to the Alt.
partial modifier_keys
xkb_symbols "right_alt" {
key <LALT> { [ Alt_L, Meta_L ] };
key <RALT> { type[Group1] = "TWO_LEVEL",
symbols[Group1] = [ Control_R, Control_R ] };
modifier_map Mod1 { Alt_L, Alt_R, Meta_L, Meta_R };
modifier_map Control { <LCTL>, <RALT> };
};
And substitute include "altwin(meta_alt)"
to the include "altwin(right_alt)"
in the latter.
Answered by ilyuha21st on November 28, 2021
If you are one of the unfortunate people like me that could not get xmodmap to switch right Alt with right Ctrl, then maybe this will help.
If you press right Alt and e and you get é then this solution is for you (needs improvement).
Run this in the terminal (check your keycodes with xev):
xmodmap -e "keycode 108 = Alt_R Meta_R Alt_R Meta_R"
then put this code in your .Xmodmap:
remove Control = Control_R
remove Mod1 = Alt_R
keycode 105 = Alt_R
keycode 108 = Control_R
add Control = Control_R
add Mod1 = Alt_R
This code sets your Alt_Gr key to Alt_R, and then it swaps Alt_r with Ctrl_R.
If you want this to remain after you logout, put the following commands in any of your startup shell files, for example ~/.profile:
if [ -f $HOME/.Xmodmap ]; then
xmodmap -e "keycode 108 = Alt_R Meta_R Alt_R Meta_R"
/usr/bin/xmodmap $HOME/.Xmodmap
fi
Answered by Mugur 'Bud' Chirica on November 28, 2021
You should be able to simply use Keyboard Layout >> Options >> Ctrl key position >> Right Alt as Right Ctrl, but this doesn't work. This has already been filed against Debian as Bug#663218
Start fresh by deleting ~/.Xmodmap
.
Note that you do not need to clear Control and Mod1. This makes it easier to change only what you want. Your ~/.Xmodmap
shoud be:
!Swap right control and right alt
remove Control = Control_R
remove Mod1 = Alt_R
keycode 105 = Alt_R
keycode 108 = Control_R
add Control = Control_R
add Mod1 = Alt_R
Answered by chaskes on November 28, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP