4

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.

  • Try this command: setxkbmap -option altwin:ctrl_win – Gunnar Hjalmarsson Sep 15 '17 at 23:53
  • @GunnarHjalmarsson - Thanks! It did work, but then I restarted the PC, and now, it doesn't. Actually it behaves weirdly, i.e. LWin+d gives 'd', but LWin+c gives nothing, at least in a text editor. In terminal it produces ^X@sc How can I make my changes to be permanent, between reboots? – konrados Sep 16 '17 at 1:01
  • I posted an answer, including how to do it persistently. – Gunnar Hjalmarsson Sep 16 '17 at 1:36
3

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.

  • Thanks! However, changing it temporarily works fine, but trying to make it persistent does not. I did restore all my /usr/share/X11/xkb/symbols files to the default ones (before my changes), I also looked for all the files named 'keyboard' hoping that maybe some file overrides the one located in /etc/default/keyboard, but there nothing like it. Can I maybe just add the setxkbmap command to some autostart file, like $HOME/.bashrc or something? – konrados Sep 16 '17 at 2:04
  • @konrados: Then there is probably some user setting which overrides the value in /etc/default/keyboard. What's the output of this command: gsettings get org.gnome.desktop.input-sources xkb-options – Gunnar Hjalmarsson Sep 16 '17 at 2:20
  • The output is: "@as []" - without quotes. – konrados Sep 16 '17 at 2:28
  • @konrados: Which desktop environment are you using? – Gunnar Hjalmarsson Sep 16 '17 at 3:21
  • It is KDE. And the OS is Ubuntu Xenial. I didn't change any files related to keyboard, except the ones in /usr/share/X11/xkb/symbols which I later restored from backup to the original ones. – konrados Sep 16 '17 at 5:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.