Mac-like Umlaut Composition on Archlinux

From time to time I need to type in German under English keyboard lay out.
On Mac, I can simply type option + u to get the umlaut, then type a, u, o, to get ä, ü, ö respectively.

I would like to have similar keystrokes on Archlinux.

It turns out to be rather simple. Suppose you have US keyboard layout as the default. Then type in

setxkbmap us mac

You will get almost the same as on the mac, except for that now the option key is AltGr(the right alt key).

If you want the left alt key function as the option key, just add

include "level3(lalt_switch)"


include "level3(ralt_switch)"

in the mac section of file /usr/share/X11/xkb/symbols/us