Make Apple CMD/Command key an additional CTRL/Control key in X11

If you want to use shortcuts in Linux/X11 as you are used to in OSX, you can configure X11 to use the CMD key as an additional CTRL key. Your muscle memory of CMD+c, CMD+s, CMD+v will not betray you anymore, then.

Since Linux is highly configurable, we can just tamper with the keymap.

1. Create a file ~/.Xmodmap

! clear CMD of it's regular task, whatever that might be
clear mod4

! configure CTRL and CMD to act as left Control
keycode 133 = Control_L NoSymbol Control_L
keycode 37 = Control_L NoSymbol Control_L

! use CTRL and CMD to act as left Control
add control = Control_L

Note: This works for my Macbook Pro (early 2011) with US layout. Your machine may use different keycodes. You can find out easily which is your CMD key, though. Just look for “Super_L” in your current keymap.

➜  ~  xmodmap -pke | grep Super_L
keycode 133 = Super_L NoSymbol Super_L

2. Load keymap patch

xmodmap ~/.Xmodmap

3. Autoloading

When this works for you (try copy/pasting/saving), then make sure to autoload .Xmodmap on start of X11. I do that using my window manager I3, but you also might add something similar to .xinitrc or .xsession

echo "exec xmodmap ~/.Xmodmap &" >> .i3/config

Category: articles | Tags: , , , , , Comment »

Leave a Reply