Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mapping Super Keys to Control in xorg.conf?

I've been attempting to switch my super and control keys in X on a macbook and have been half successful. I'd like to avoid creating a custom .Xmodmap if possible, as there is a temporary 100% cpu bug that pops up every time the custom map is loaded.

After some diging, I ended up putting Option "XkbOptions" "altwin:ctrl_win" in my 01-keyboard-layout.conf file which has gotten me halfway there: for eg, left command now maps to 133 Control_L.

However, the control keys remain the same. Left control, for eg still maps to 37 Control_L.

Looking through evdev.lst (and a bunch of googling) turned up no relevant XkbOption for turning control keys into supers, and now i'm pretty stuck.

Any ideas?

like image 786
jake madison Avatar asked Dec 30 '12 20:12

jake madison


1 Answers

Ok, I did finally get this to work.

First, these two resources are amazing for anyone wanting to delve into this mess:

http://madduck.net/docs/extending-xkb/ & http://www.charvolant.org/~doug/xkb/html/index.html

For anyone specifically trying to do this switchover, this is what I did:

1) create a file in /usr/share/X11/xkb/symbols for your new mapping 2) put this in it:

// Control is SWAPPED with Win-keys 
partial modifier_keys
xkb_symbols "cmd_n_ctrl" {
    key <LWIN> {        [       Control_L               ]       };
    key <RWIN> {        [       Control_R               ]       };
    key <LCTL> {       [       Super_L         ]       };
    modifier_map Control { <LWIN>, <RWIN> };
    modifier_map Mod4 { <LCTL> };
};

3: edit evdev in /usr/share/X11/xkb/rules to include:

altwin2:cmd_n_ctrl               =       +altwin2(cmd_n_ctrl)

(under the option = symbols section)

4: add your new option to evdev.lst (same dir):

altwin2:cmd_n_ctrl

(under the option section)

5: now edit your 01-Keyboard conf file to include the new option that you've created. Mine looks like this:

Section "InputClass"
        Identifier "keyboard-layout"
        Driver "evdev"
        MatchIsKeyboard "yes"
        Option "XkbLayout" "us, ru, ca, fr"
        Option "XkbOptions" "altwin2:cmd_n_ctrl"
EndSection

6: reboot and you should be good to go.

The above resources are way better at explaining all of this, or any snags you might run into. There is probably a much better way to do this (probably not altering the contents of /usr/share), but so far, this is what got me up and running.

Hope that helps someone else stuck in this spot!

like image 149
jake madison Avatar answered Sep 28 '22 09:09

jake madison