You are not logged in.

#1 2012-01-25 08:01:19

cyker
Member
Registered: 2009-05-30
Posts: 86

[SOLVED] Add a custom keyboard layout in X

I'd like to discard QWERTY and start using Dvorak. However, I find it may be easier to accustom myself to Dvorak if I exchange its left-hand keys with right-hand ones.

So I want to create a custom keyboard layout. By inspecting /usr/share/X11/xkb, I found there are two methods to specify keyboard layout: by keymaps (seems to be deprecated) and by rules. Both methods will then determine and incorporate keycodes, types, compat, symbols, and geometry.

Of course I can directly modify existing configurations (for example, to change symbols). But these settings will be gone once I update the package xkeyboard-config.

Then my question is: Is it possible to add a custom keyboard layout in the user's home directory in a pluggable way?

Anything about how to add separate keyboard layouts in system folders (say /usr/share/X11/xkb) are also welcome so I can create a separate package which doesn't clash with xkeyboard-config. Thanks.

PS. I know xmodmap-based methods, but I prefer an original layout which can be loaded and unloaded with setxkbmap.

Last edited by cyker (2012-01-25 15:50:00)


.

Offline

#2 2012-01-25 12:21:47

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,018

Re: [SOLVED] Add a custom keyboard layout in X

If you use ext, you can use "chattr +i filename" to stop the file from being modified - that way you can make sure your changes don't get lost on the update. I have put a colemak file in /usr/share/X11/xkb/symbols/ and can simply load it with "setkxbmap colemak", but I don't really know the magic behind layout settings.

For reference, my colemak file, with polish diacritics:

// Colemak symbols for xkb on X.Org Server 7.x
// 2006-01-01 Shai Coleman, http://colemak.com/ . Public domain.

partial default alphanumeric_keys
xkb_symbols "basic" {
    include "us(basic)"
    name[Group1]= "Colemak";

    // Alphanumeric section
    key <TLDE> { [        grave,   asciitilde,      dead_tilde,       asciitilde ] };
    key <AE01> { [            1,       exclam,      exclamdown,      onesuperior ] };
    key <AE02> { [            2,           at,       masculine,      twosuperior ] };
    key <AE03> { [            3,   numbersign,     ordfeminine,    threesuperior ] };
    key <AE04> { [            4,       dollar,            cent,         sterling ] };
    key <AE05> { [            5,      percent,        EuroSign,              yen ] };
    key <AE06> { [            6,  asciicircum,         hstroke,          Hstroke ] };
    key <AE07> { [            7,    ampersand,             eth,              ETH ] };
    key <AE08> { [            8,     asterisk,           thorn,            THORN ] };
    key <AE09> { [            9,    parenleft,  leftsinglequotemark,  leftdoublequotemark ] };
    key <AE10> { [            0,   parenright, rightsinglequotemark,  rightdoublequotemark ] };
    key <AE11> { [        minus,   underscore,          endash,           emdash ] };
    key <AE12> { [        equal,         plus,        multiply,         division ] };

    key <AD01> { [            q,            Q,      adiaeresis,       Adiaeresis ] };
    key <AD02> { [            w,            W,           aring,            Aring ] };
    key <AD03> { [            f,            F,          atilde,           Atilde ] };
    key <AD04> { [            p,            P,          oslash,         Ooblique ] };
    key <AD05> { [            g,            G,     dead_ogonek,       asciitilde ] };
    key <AD06> { [            j,            J,         dstroke,          Dstroke ] };
    key <AD07> { [            l,            L,         lstroke,          Lstroke ] };
    key <AD08> { [            u,            U,          uacute,           Uacute ] };
    key <AD09> { [            y,            Y,      udiaeresis,       Udiaeresis ] };
    key <AD10> { [    semicolon,        colon,      odiaeresis,       Odiaeresis ] };
    key <AD11> { [  bracketleft,    braceleft,   guillemotleft,        0x1002039 ] };
    key <AD12> { [ bracketright,   braceright,  guillemotright,        0x100203a ] };
    key <BKSL> { [    backslash,          bar,      asciitilde,       asciitilde ] };

    key <AC01> { [            a,            A,          aogonek,         Aogonek ] };
    key <AC02> { [            r,            R,      dead_grave,       asciitilde ] }; 
    key <AC03> { [            s,            S,          sacute,           Sacute ] }; 
    key <AC04> { [            t,            T,      dead_acute, dead_doubleacute ] };
    key <AC05> { [            d,            D,  dead_diaeresis,       asciitilde ] };
    key <AC06> { [            h,            H,      dead_caron,       asciitilde ] };
    key <AC07> { [            n,            N,          nacute,           Nacute ] };
    key <AC08> { [            e,            E,         eogonek,          Eogonek ] };
    key <AC09> { [            i,            I,         iumlaut,          Iumlaut ] };
    key <AC10> { [            o,            O,          oacute,           Oacute ] };
    key <AC11> { [   apostrophe,     quotedbl,          otilde,           Otilde ] }; 

    key <AB01> { [            z,            Z,       zabovedot,        Zabovedot ] };
    key <AB02> { [            x,            X,          zacute,           Zacute ] };
    key <AB03> { [            c,            C,          cacute,           Cacute ] };
    key <AB04> { [            v,            V,              oe,               OE ] };
    key <AB05> { [            b,            B,      dead_breve,       asciitilde ] };
    key <AB06> { [            k,            K,  dead_abovering,       asciitilde ] };
    key <AB07> { [            m,            M,     dead_macron,       asciitilde ] };
    key <AB08> { [        comma,         less,    dead_cedilla,       asciitilde ] };
    key <AB09> { [       period,      greater,   dead_abovedot,       asciitilde ] };
    key <AB10> { [        slash,     question,    questiondown,       asciitilde ] };

    key <CAPS> { [    BackSpace,    BackSpace,       BackSpace,        BackSpace ] };
    key <LSGT> { [        minus,   underscore,          endash,           emdash ] };
    key <SPCE> { [        space,        space,           space,     nobreakspace ] };

    include "level3(ralt_switch)"
};

Offline

#3 2012-01-25 14:27:58

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: [SOLVED] Add a custom keyboard layout in X

I use a custom layout.  It's defined in /usr/share/X11/xkb/symbols/carpalx.  It's fully integrated in the sense that I can switch to it with 'setxkbmap carpalx'.  But since it isn't part of any package, it's safe from overwrite during upgrades.

For reference, the file can be found here.

Last edited by alphaniner (2012-01-25 14:34:41)


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#4 2012-01-25 15:47:43

cyker
Member
Registered: 2009-05-30
Posts: 86

Re: [SOLVED] Add a custom keyboard layout in X

alphaniner wrote:

I use a custom layout.  It's defined in /usr/share/X11/xkb/symbols/carpalx.  It's fully integrated in the sense that I can switch to it with 'setxkbmap carpalx'.  But since it isn't part of any package, it's safe from overwrite during upgrades.

For reference, the file can be found here.

Thanks alphaniner, it works! But I'm still interested in the contents of /usr/share/X11/xkb/symbols.dir. For example, what does

-dp----- a------- carpalx(qgmlwb)

mean?

Last edited by cyker (2012-01-25 15:48:26)


.

Offline

#5 2012-01-25 16:17:39

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: [SOLVED] Add a custom keyboard layout in X

First of all, I didn't create the file.  Just to make it clear.

That said, I think the 'd' stands for default and the 'p' stands for partial.  No idea about the 'a'.

Also, I don't think I ever made those changes to symbols.dir.  I'm not too good at following directions smile

I can say though that the current version of symbols.dir has no references to carpalx, and setkbmap works just fine.

Last edited by alphaniner (2012-01-25 16:18:39)


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

Board footer

Powered by FluxBB