The suggestion by @Ian did not help on my system, a MacBook with Ubuntu installed. Here is my solution.
German keyboards of Macs lack frequently used keys like backslash, the pipe symbol, or curly and square brackets. Under MacOs, these are mapped to Alt-5
to Alt-9
, where Alt
is the left Alt-key. Ubuntu, however, maps them by default to the right Alt-key, which is not only confusing when using both MacOs and Linux, but even difficult to enter (the backslash is Alt-Shift-7
). I have thus mapped the modifier key to the left Alt-key for compatibility with MacOs with the following entries in .Xmodmap
:
clear mod1
clear mod5
keycode 108 = Alt_L
keycode 64 = ISO_Level3_Shift
add mod5 = ISO_Level3_Shift Meta_L
add mod1 = Alt_L Mode_switch
This works for every application except Emacs, which apparently maps Alt-combinations to something different (which seems to be just nothing, but this prevents entering special characters). To make these characters work, I had to explicitly bind them in .emacs
with
(global-set-key (kbd "M-7") (lambda () (interactive) (insert "|")))
(global-set-key (kbd "M-/") (lambda () (interactive) (insert "\\")))
(global-set-key (kbd "M-5") (lambda () (interactive) (insert "[")))
(global-set-key (kbd "M-6") (lambda () (interactive) (insert "]")))
(global-set-key (kbd "M-8") (lambda () (interactive) (insert "{")))
(global-set-key (kbd "M-9") (lambda () (interactive) (insert "}")))
(global-set-key (kbd "M-l") (lambda () (interactive) (insert "@")))
Which key code actually is required by the kbd
function can be figured out within Emacs with Ctrl-h k
and then entering the key combination.