Xmodmap configuration that swaps ctrl and cmd keys to achieve macOS-like behaviour.
-
Open or create
.Xmodmap
file in your~/
folder. -
Paste the following code into that file:
! -*- coding: utf-8 -*- ! macOS-like key mapping ! default mapping ! keycode 37 = Control_L NoSymbol Control_L ! keycode 64 = Alt_L Meta_L Alt_L Meta_L ! keycode 92 = ISO_Level3_Shift NoSymbol ISO_Level3_Shift ! keycode 105 = Control_R NoSymbol Control_R ! keycode 108 = ISO_Level3_Shift NoSymbol ISO_Level3_Shift ! keycode 133 = Super_L NoSymbol Super_L ! keycode 134 = Super_R NoSymbol Super_R ! keycode 204 = NoSymbol Alt_L NoSymbol Alt_L ! keycode 206 = NoSymbol Super_L NoSymbol Super_L ! moddified mapping clear control clear mod1 clear mod4 clear mod5 keycode 37 = Super_L NoSymbol Super_L keycode 108 = Alt_R NoSymbol Alt_R keycode 133 = Control_L NoSymbol Control_L keycode 134 = Control_R NoSymbol Control_R add control = Control_L Control_R add mod1 = Alt_L Meta_L add mod4 = Super_L Super_R add mod5 = Alt_R Meta_R
-
Run the following command in terminal and compare your values with the default mapping values in provided
.Xmodmap
config:xmodmap -pke | grep -P '(Control|Super|Alt|Level3)'
- If your keycodes values are different, you will need to remap these by yourself. You can run
xmodmap -pke
to print out all keycodes or usexev
utility (help).
- If your keycodes values are different, you will need to remap these by yourself. You can run
-
Apply the changes:
xmodmap ~/.Xmodmap
- This modification does not replicate the macOS terminal controls (i.e. ctrl+c to cancel). A workaround for this limitation is possible with AutoKey scripts.