The Linux kernel generates a code each time a key is pressed on a keyboard. That code is compared to a table of keycodes
defining a figure that is then displayed.
This process is complicated by Xorg
, which starts its own table of keycodes
. Each keycode
can belong to a keysym
. A keysym
is like a function, started by typing a key. Xmodmap
allows you to edit these keycode-keysym
relations.
To get the current keymap table using Xmodmap
use:
xmodmap -pke
This will print out the full table in the following format:
keycode <keycode#> = <boundkey> <boundkey>
Before moving anything around be sure to backup the original keycode
layout using xmodmap -pke >> $HOME/Xmodmap.orig
This will place the file Xmodmap.orig
in your users home directory.
Tip: There are also some predefined keycodes (e.g. XF86AudioMute
, XF86Mail
). Those keycodes can be found in: /usr/include/X11/XF86keysym.h
You can also also edit the keys: Shift
, Ctrl
, Alt
and Super
(there always exists a left and a right one (Alt_R=AltGr
)).
Here's a quick example of how your configuration would look if you wanted to swap CTRL
and Super
(Windows Key):
keycode 255 =
!add Shift = Shift_L Shift_R
!add Lock = Caps_Lock
add Control = Super_L Super_R
!add Mod1 = Alt_L Alt_R
!add Mod2 = Mode_switch
!add Mod3 =
add Mod4 = Control_L Control_R
!add Mod5 =
(the !
is used to comment / ignore the line. in this example only Super
and Control
keys get adjusted)
This configuration would be saved in $HOME/.Xmodmap
and loaded with
xmodmap ~/.Xmodmap
You could also start this with xwindows by adding it to your ~/.xinitrc
And if things get hairy you can always revert back to Xmodmap.org
.
Any bindings for applications that rely on these keys would also be moved. So make sure that everything remains bound so you don't lose any functionality. It's a tug-of-war match.
Thanks to @Gilles, I found an answer. So, the problem was with different Input Methods, used by different applications; and IMs in turn use different Compose files — ones used by X are /usr/share/X11/locale/<your-locale>/Compose
and ~/.XCompose
(the last isn't present by default, but you may create it for custom combinations), and the one used by Qt is in… Well, looks like nobody knows.
The solution is to set xim
to be used as default input method by all applications. You can call im-config
, and choose there xim as the default input method, or you can manually edit /etc/profile
file to add these lines:
export GTK_IM_MODULE=xim
export XMODIFIERS=@im=xim
export QT_IM_MODULE=xim
Not sure about im-config
, but for the way with /etc/profile
reboot will be needed.
Best Answer
I don't know what's causing this problem or how to fix this, but I can offer a workaround for most purposes.
Normally, dead keys are processed at a very low input layer, not even visible from Lisp. But you can do the processing in Lisp.
If you want the keys to act as dead keys:
There is already a limited mechanism for dead keys in Lisp, designed for 8-bit character sets on machines that don't have any way to input non-ASCII characters. If you type
C-x 8
followed by an accent and a letter, the corresponding accented letter is inserted, thanks to theiso-transl
library. We can copy this mechanism. Put this in your.emacs
:The map
key-translation-map
rewrites key sequences as they are entered, so this will make dead ` a equivalent to à for most purposes. Explicitly setting entries inisearch-mode-map
tonil
is necessary because otherwise pressing a dead key would exit isearch before the translation could kick in.If you want the accent characters to be inserted immediately