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.

Kaz Wolfe
  • 34,122
  • 21
  • 114
  • 172
konrados
  • 213
  • 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 01:01
  • I posted an answer, including how to do it persistently. – Gunnar Hjalmarsson Sep 16 '17 at 01:36

1 Answers1

4

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.

Gunnar Hjalmarsson
  • 33,540
  • 3
  • 64
  • 94
  • 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 02: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 02:20
  • The output is:

    "@as []" - without quotes.

    – konrados Sep 16 '17 at 02:28
  • @konrados: Which desktop environment are you using? – Gunnar Hjalmarsson Sep 16 '17 at 03: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 05:52
  • @konrados: I see. Then I suspect there is some KDE specific user setting which overrides the system wide settings in /etc/default/keyboard, but I can't tell where. Noticed https://askubuntu.com/q/678812, but that answer isn't very specific. Hopefully someone knowing KDE chimes in and helps. – Gunnar Hjalmarsson Sep 16 '17 at 13:37
  • I simply added the setxkbmap -option altwin:ctrl_win command to my autostart ( ~/.config/autostart ) and it works like a charm! Thank you!!! BTW, I have too low reputation to vote up :( But I'll be back here, when I'll have :) Thank you very very much for your time and the solution! – konrados Sep 16 '17 at 19:10