mildred593 (mildred593) wrote in xkbconfig,
mildred593
mildred593
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
Subscribe
  • Post a new comment

    Error

    default userpic
    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 2 comments
xkb option "altwin:ctrl_win" will map your ?WIN keys to Control_?

The option to map ?CTL to Super_? can be added.

If you map both LALT and RALT to level3 shift - you won't have any Alt as such (for shortcuts etc). Is that what you want?

Well, my solution was a bit trickier.

It seems the option altwin:ctrl_win is part of what I want, but not entirely. This option will create a control key in place of the <?WIN> keys. Then both <?CTL> and <?WIN> keys would be control keys.

What I want is to make a control key out of <?WIN> and make a Super key out of the <?CTL>. (That way I still have super keys)

And now, in order to keep the possibility to use Alt shortcts (Alt-F for example to open the File menu). I associate the <?CTL> key (that have the Super symbol) to the modifier Mod1. This way, I can access the Alt shortcuts using the physical control keys.

This is the best solution I found for now. I'd rather keep the Alt shortcuts on the alt keys, but I can't seem to find a way for that.


The only problem with my solution is that the "CTRL+ALT" type doesn't match with the physical Ctrl and Alt keys. For that, I did:
    type "CTRL+ALT" {
      modifiers = Mod1+Alt;
      map[Mod4+Alt] = Level2;
      level_name[Level1] = "Base";
      level_name[Level2] = "Ctrl+Alt";
    };