Ubuntu – Trying to remap the left SUPER key (also called WINDOWS key) to left or right CONTROL key, with xkg

keyboard-layoutxkb

I've tried to read and understand this: https://www.charvolant.org/doug/xkb/html/node5.html

As a test, since my layout is "Polish, programmer" in the /usr/share/X11/xkb/symbols/pl file I played with remapping the 'q' character to 'x', and it worked just fine.

But what I want, is to remap LWIN (Left Super) to Left Control.

So I tried this:
I started editing /usr/share/X11/xkb/symbols/pc file, assuming this is the 'root' of all the other files.
Commented out this line:

//key <LWIN> {  [ Super_L       ]   };

and added this one:

key <LWIN> {    [ Control_L     ]   };

and rebooted PC, with no success. I.e. LWIN + C, doesn't copy selected text in text editors to clipboard, instead it just produces the 'c' letter. In the terminal instead of stopping current programm it also just produces the 'c' letter.

Here is my config file:
https://gist.github.com/anonymous/49514ddf6f03ba87babaab51e2d5eff4

When I try the xev command and then press the Left Control Key, I see this:

KeyPress event, serial 40, synthetic NO, window 0x5a00001,
    root 0x7e, subw 0x0, time 1053321, (374,-259), root:(374,545),
    state 0x0, keycode 133 (keysym 0xffe3, Control_L), same_screen YES,
    XKeysymToKeycode returns keycode: 37
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 40, synthetic NO, window 0x5a00001,
    root 0x7e, subw 0x0, time 1053425, (374,-259), root:(374,545),
    state 0x0, keycode 133 (keysym 0xffe3, Control_L), same_screen YES,
    XKeysymToKeycode returns keycode: 37
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

BTW. Ask ubuntu suggests me two links to similar questions, but they are old, and suggest using xmodmap, and afaik it's no longer correct answer on Ubuntu >= 16.04 (Xenial) and this is precisely the version I have.

BTW2. I would really like to avoid using apps like Xbindkeys, considering there is a built in solution, which I guess I almost understand, and already spent some time on trying to understand it.

Best Answer

To change it temporarily, you can run this command:

setxkbmap -option altwin:ctrl_win

To change it persistently, open the /etc/default/keyboard file for editing, change the line

XKBOPTIONS=""

to

XKBOPTIONS="altwin:ctrl_win"

and reboot.