mildred593 (mildred593 ) wrote in xkbconfig ,

XKB options: swap Ctrl and Super (windows) key

Hi, I haven't found a mailing list on the freedesktop wiki, so I assume this place is as good as any other place. I wanted to ask for a feature to be implemented in the xkb layouts. So, let me explain. i have a macintosh (macintel) keyboard and even if I seldom uses Mac OS X, I'd like to have a similar layout as in Mac OS X. Especially around the special keys around the spacebar (control, alt, ...) Here is how my keyboard (a laptop) looks like (on the lowest row of keys):


<LCTL> <LALT> <LWIN> <SPCE> <RWIN> <KPEN>
Here is how a desktop mac keyboard would look like on the same row.


<LCTL> <LALT> <LWIN> <SPCE> <RWIN> <RALT> <RCTL>
Now, on X11, the main modifier key is Control (<LCTL>, <RCTL>), while on Mac OS X, the main modifier key is command (or the windows key, it has the same keycode. <LWIN> <RWIN>). On Mac OS X, we can choose the third level (the equivalent of AltGr on PC keyboards) using any of the alt keys alone (<LALT>, <RALT>). When used in combination with the command key (<LWIN>, <RWIN>), the third level is not chosen. I tried to create an XKB map that would be as close to this behaviour as possible, but I couldn't succeed. The problem is that i couldn't find a way that Alt would trigger the third level if pressed alone, but not if pressed with another modifier. My solution was to map the keys as follows:



key <LCTL> to symbol Super_L and modifier Mod1 (Alt)
key <RCTL> to symbol Super_R and modifier Mod1 (Alt)
key <LALT> to symbol Alt_L and modifier Mod5 (level3 shift)
key <RALT> to symbol Alt_R and modifier Mod5 (level3 shift)
key <LWIN> to symbol Control_L and modifier Control
key <RWIN> to symbol Control_R and modifier Control
The exact code I used was:



  xkb_symbols   {

      // --------------
      // Default keymap
      // --------------

      include "pc"
      include "macintosh_vndr/fr"
      include "inet(evdev)"

      // ---------------
      // Command (cmd ⌘)
      // ---------------

      include "altwin(ctrl_win)"

      // -------------------
      // Control (ctrl) keys
      // -------------------

      key <LCTL> { [ Super_L, Super_L ] };
      key <RCTL> { [ Super_R, Super_R ] };
      modifier_map Mod1 { <LCTL>, <RCTL> };

      // ----------------
      // Alt (alt ⌥) keys
      // ----------------

      include "level3(lalt_switch)"
      include "level3(ralt_switch)"
  };
Now, my only problem is that I have to use xkbcomp keymap $DISPLAY to install the keymap. And frequently, GNOME reset the keymap to the default keymap configured within GNOME. I'd really welcome these features to be included directly in xkb layouts. Probaaly in the XKB options. I think we could have something like:


partial modifier_keys
xkb_symbols "switch_lwin_lctrl" {
    key <LWIN> { [ Control_L ] };
    key <LCTL> { [ Super_L, Super_L ] };
    modifier_map Control { <LWIN> };
};

partial modifier_keys
xkb_symbols "switch_rwin_rctrl" {
    key <RWIN> { [ Control_R ] };
    key <RCTL> { [ Super_R, Super_R ] };
    modifier_map Control { <RWIN> };
};

partial modifier_keys
xkb_symbols "ctrl_key_as_mod1" {
    modifier_map Mod1 { <LCTL>, <RCTL> };
};
Then we could have something like I have using those three options plus level3(lalt_switch) and level3(ralt_switch) What do you think ? Could that be included ? Thanks. Mildred
  • Post a new comment

    Error

    default userpic
  • 2 comments