The question:
How can I remap (swap) modifier keys system-wide on Linux?
Explanation:
I want to install Debian Jessie on my PC to use it with Emacs. I have a MacBook with Emacs and use it primarily. Here is how keys are arranged on laptop:
fn ctrl alt cmd spacebar cmd alt
fn is unused in my Emacs workflow, other keys configured as listed below:
- ctrl acts as
Hyper - alt acts as
Meta - cmd acts as
Control
These configuration eases for me Emacs experience (big thumb hits Control cmd key) and I got used to this kind of key bindings.
by default alt is used as Meta, while ctrl is used as Control, the keys are swapped and big thumb lays on Meta
I want to configure my keys on Linux same way, here is what I have on my PC's keyboard:
ctrl win alt spacebar alt win menu ctrl
So, to correspond to my laptop keys, I want win keys to be mapped to Alt modifier, and alt keys to be mapped to Control modifier. In this case ctrl could be used as Super modifier, while menu could be kept untouched.
Is it possible to make such configuration system-wide on Linux (Debian)?
Finally, I have managed to achieve my goal with following configuration:
!file ~/.Xmodmap
clear control
clear mod1
clear mod4
keycode 37 = Super_L
! left Ctrl becomes Super
keycode 64 = Control_L
! left Alt becomes Control
keycode 133 = Alt_L Meta_L
! left Win becomes Alt
keycode 108 = Control_R
! right Alt becomes Control
keycode 134 = Alt_R Meta_R
! right Win becomes Alt
keycode 105 = Super_R
! right Ctrl becomes Super
add control = Control_L Control_R
add mod1 = Alt_L Meta_L
add mod4 = Super_L Super_R
Also, here is similar question with quite helpful and simple guides.