XKB madness

So I decided that rather than hacking it with Xmodmap, I would try and get the back and forward buttons (on my IBM laptop) working properly just via the xkb stuff, and did eventually manage it.

Basically in /etc/X11/xkb/symbols/inet (ubuntu, other distros will vary) put:

partial alphanumeric_keys
xkb_symbols "thinkpad" {
    key <I6A>   {       [       XF86Back                ]       };
    key <I69>   {       [       XF86Forward             ]       };
};

(how do I generate those <I6A> numbers ? it isn’t a direct conversion from the decimal that xev gives me)

and then in the $inetkbds bit of /etc/X11/xkb/rules/base add “thinkpad”. Once that is done, just select the “IBM thinkpad <random model numbers>” layout in gnome-keyboard-properties, and your back and forward buttons will ‘just work’ with no xmodmap messing.

I believe this is the correct way of doing things, so I have raised a bug about it.

Perhaps another bug should be raised about the name of that keyboard, and the fact that the keys appear as just a big black rectangle in the layouts dialog of gnome-keyboard-properties.

Next up, get my Microsoft Natural Multimedia keyboard’s audio buttons working…..

6 Responses to “XKB madness”

  1. Martijn van de Streek Says:

    You should talk to mjg59 (on freenode, #ubuntu-laptop); there’s a special startup script which loads key mappings depending on the laptop model.

    He might have ideas on how to extend it for keyboards.

  2. Marius Gedminas Says:

    The keycodes shown by xkb are mapped to symbolic names in /etc/X11/xkb/keysyms/xfree86:

    = 233;
    = 234;

  3. Marius Gedminas Says:

    Ouch. No preview button? No description of what sort of markup is acceptable in these comment forms? Here’s what I intended to quote, rewritten in HTML:

    <I69> = 233;
    <I6A> = 234;

  4. Crispin Says:

    Marius,

    Thanks! that is just what I was looking for :-)

  5. Erich Schubert Says:

    Hi,
    I’ve been using that for ages - my current setup is to have in /etc/X11/xkb/symbols/erich the following:
    partial alphanumeric_keys
    xkb_symbols “erich” {
    name[Group1]= “Erichs Thinkpad”;

    key <I6C> { [ XF86Mail ] };
    key <I32> { [ XF86Launch1 ] };
    key <I65> { [ XF86Search ] };
    key <I66> { [ XF86Launch2 ] };
    key <I67> { [ XF86Launch3 ] };
    // key <I68> { [ XF86Stop ] };
    key <I68> { [ Hyper_L ] };
    key <I69> { [ XF86Forward ] };
    key <I6A> { [ XF86Back ] };
    modifier_map Mod4 { Hyper_L };
    };

    Note that I use one of the buttons as additional modifier.
    The Back and Forward buttons are most useful for switching desktops, I love them. Mail and Search correspond to these icons on the actual buttons, I didn’t look for other matches.

    The big girpes I have are with upgrades. This is in a separate file, and thus works just fine, but I have also modifications in the “xorg”, “xorg.lst” and “xorg.xml” files, so this keyboard layout shows up in the gnome keyboard dialogs.
    Unfortunately, whenever I upgrade my Xorg version I have to merge these changes in the configuration files…
    And currently, Xkb is somehow broken - on each login I get the message that it doesn’t work, but the layout is just fine - and I have absolutely no clue how to fix it…
    When I change something with the keyboard settings, the GTK theme reverts to default and then comes back to my setting - looks like a crashing gnome-settings-daemon to me…

  6. Marius Gedminas Says:

    I used to have a custom XKB keymap in a Debian package that used diversions to survive upgrades. It broke after the xkb directory got reoganized, and I couldn’t be bothered to update it. These days I have a shell script with xmodmap commands to remap a couple of keys, and I run it late from gnome-session, after GNOME has had the chance to load its own keymap.


Bad Behavior has blocked 2 access attempts in the last 7 days.