setxkbmap manual

Hi!

This is probably a stupid question: can someone help me find a link to a thorough description of 'setxkbmap', please? I can't seem to find one.

Incidentally, I can't seem to use a full 'us-international' keyboard layout. I tried '-layout us_intl', which turned out that the AltGr-key is not fully functioning; I also tried '-layout us -variant intl', in which case, the AltGr-key seemed to work well, but the accents did not work. Is there a thorough description about what options I can use?

Thanks!
 
What lang do you want to switch?
here's what I use
Code:
# Latvian native lang with AltGr
setxkbmap lv
# Russian phonetic
setxkbmap ru phonetic
# Russian
setxkbmap ru
# Latvian with apostrophe
setxkbmap lv apostrophe
 
Well, like I said, mostly I just want to use the us-international layout; specifically, it's for French.


killasmurf86 said:
What lang do you want to switch?
here's what I use
Code:
# Latvian native lang with AltGr
setxkbmap lv
# Russian phonetic
setxkbmap ru phonetic
# Russian
setxkbmap ru
# Latvian with apostrophe
setxkbmap lv apostrophe
 
shuxuef said:
Well, like I said, mostly I just want to use the us-international layout; specifically, it's for French.

I found this
Code:
setxkbmap ca -variant fr
This doesn't work with AltGr, but it does with apostrophe

Now you need to find how to make it work with AltGR
 
So I guess it's kind of implied that there is not a 'thorough' description on the options for setxkbmap then?
 
shuxuef said:
Incidentally, I can't seem to use a full 'us-international' keyboard layout. I tried '-layout us_intl', which turned out that the AltGr-key is not fully functioning; I also tried '-layout us -variant intl', in which case, the AltGr-key seemed to work well, but the accents did not work.
When you press ', does it give you an apostrophe or do nothing?

If it gives an apostrophe, I don’t know how to fix that. But doing nothing is a symptom of an incomplete compose file. X11 uses xkb to assign a dead key action like an accent to a physical key, but uses Compose(5) to assign sequences to them. So you can customize what the dead keys do that way.

For instance, my $HOME/.XCompose looks like this:
Code:
<dead_grave> <A> : "À"
<dead_acute> <A> : "Á"
<dead_circumflex> <A> : "Â"
<dead_tilde> <A> : "Ã"
<dead_diaeresis> <A> : "Ä"
<dead_abovering> <A> : "Ã…"
<dead_cedilla> <C> : "Ç"
<dead_grave> <E> : "È"
<dead_acute> <E> : "É"
<dead_circumflex> <E> : "Ê"
<dead_diaeresis> <E> : "Ë"
<dead_grave> <I> : "Ì"
<dead_acute> <I> : "Í"
<dead_circumflex> <I> : "ÃŽ"
<dead_diaeresis> <I> : "Ï"
<dead_tilde> <N> : "Ñ"
<dead_grave> <O> : "Ã’"
<dead_acute> <O> : "Ó"
<dead_circumflex> <O> : "Ô"
<dead_tilde> <O> : "Õ"
<dead_diaeresis> <O> : "Ö"
<dead_stroke> <O> : "Ø"
<dead_grave> <U> : "Ù"
<dead_acute> <U> : "Ú"
<dead_circumflex> <U> : "Û"
<dead_diaeresis> <U> : "Ü"
<dead_acute> <Y> : "Ý"
<dead_grave> <a> : "à"
<dead_acute> <a> : "á"
<dead_circumflex> <a> : "â"
<dead_tilde> <a> : "ã"
<dead_diaeresis> <a> : "ä"
<dead_abovering> <a> : "Ã¥"
<dead_cedilla> <c> : "ç"
<dead_grave> <e> : "è"
<dead_acute> <e> : "é"
<dead_circumflex> <e> : "ê"
<dead_diaeresis> <e> : "ë"
<dead_grave> <i> : "ì"
<dead_acute> <i> : "í"
<dead_circumflex> <i> : "î"
<dead_diaeresis> <i> : "ï"
<dead_tilde> <n> : "ñ"
<dead_grave> <o> : "ò"
<dead_acute> <o> : "ó"
<dead_circumflex> <o> : "ô"
<dead_tilde> <o> : "õ"
<dead_diaeresis> <o> : "ö"
<dead_stroke> <o> : "ø"
<dead_grave> <u> : "ù"
<dead_acute> <u> : "ú"
<dead_circumflex> <u> : "û"
<dead_diaeresis> <u> : "ü"
<dead_acute> <y> : "ý"
<dead_diaeresis> <y> : "ÿ"
<dead_macron> <A> : "Ä€"
<dead_macron> <a> : "ā"
<dead_breve> <A> : "Ä‚"
<dead_breve> <a> : "ă"
<dead_ogonek> <A> : "Ä„"
<dead_ogonek> <a> : "Ä…"
<dead_acute> <C> : "Ć"
<dead_acute> <c> : "ć"
<dead_circumflex> <C> : "Ĉ"
<dead_circumflex> <c> : "ĉ"
<dead_abovedot> <C> : "ÄŠ"
<dead_abovedot> <c> : "Ä‹"
<dead_caron> <C> : "Č"
<dead_caron> <c> : "č"
<dead_caron> <D> : "ÄŽ"
<dead_caron> <d> : "ď"
<dead_stroke> <D> : "Đ"
<dead_stroke> <d> : "Ä‘"
<dead_macron> <E> : "Ä’"
<dead_macron> <e> : "Ä“"
<dead_breve> <E> : "Ä”"
<dead_breve> <e> : "Ä•"
<dead_abovedot> <E> : "Ä–"
<dead_abovedot> <e> : "Ä—"
<dead_ogonek> <E> : "Ę"
<dead_ogonek> <e> : "Ä™"
<dead_caron> <E> : "Äš"
<dead_caron> <e> : "Ä›"
<dead_circumflex> <G> : "Ĝ"
<dead_circumflex> <g> : "ĝ"
<dead_breve> <G> : "Äž"
<dead_breve> <g> : "ÄŸ"
<dead_abovedot> <G> : "Ä "
<dead_abovedot> <g> : "Ä¡"
<dead_cedilla> <G> : "Ä¢"
<dead_cedilla> <g> : "Ä£"
<dead_circumflex> <H> : "Ĥ"
<dead_circumflex> <h> : "Ä¥"
<dead_stroke> <H> : "Ħ"
<dead_stroke> <h> : "ħ"
<dead_tilde> <I> : "Ĩ"
<dead_tilde> <i> : "Ä©"
<dead_macron> <I> : "Ī"
<dead_macron> <i> : "Ä«"
<dead_breve> <I> : "Ĭ"
<dead_breve> <i> : "Ä­"
<dead_ogonek> <I> : "Ä®"
<dead_ogonek> <i> : "į"
<dead_abovedot> <I> : "Ä°"
<dead_circumflex> <J> : "Ä´"
<dead_circumflex> <j> : "ĵ"
<dead_cedilla> <K> : "Ķ"
<dead_cedilla> <k> : "Ä·"
<dead_acute> <L> : "Ĺ"
<dead_acute> <l> : "ĺ"
<dead_cedilla> <L> : "Ä»"
<dead_cedilla> <l> : "ļ"
<dead_caron> <L> : "Ľ"
<dead_caron> <l> : "ľ"
<dead_stroke> <L> : "Ł"
<dead_stroke> <l> : "Å‚"
<dead_acute> <N> : "Ń"
<dead_acute> <n> : "Å„"
<dead_cedilla> <N> : "Å…"
<dead_cedilla> <n> : "ņ"
<dead_caron> <N> : "Ň"
<dead_caron> <n> : "ň"
<dead_macron> <O> : "Ō"
<dead_macron> <o> : "ō"
<dead_breve> <O> : "ÅŽ"
<dead_breve> <o> : "ŏ"
<dead_acute> <R> : "Å”"
<dead_acute> <r> : "Å•"
<dead_cedilla> <R> : "Å–"
<dead_cedilla> <r> : "Å—"
<dead_caron> <R> : "Ř"
<dead_caron> <r> : "Å™"
<dead_acute> <S> : "Åš"
<dead_acute> <s> : "Å›"
<dead_circumflex> <S> : "Ŝ"
<dead_circumflex> <s> : "ŝ"
<dead_cedilla> <S> : "Åž"
<dead_cedilla> <s> : "ÅŸ"
<dead_caron> <S> : "Å "
<dead_caron> <s> : "Å¡"
<dead_cedilla> <T> : "Å¢"
<dead_cedilla> <t> : "Å£"
<dead_caron> <T> : "Ť"
<dead_caron> <t> : "Å¥"
<dead_stroke> <T> : "Ŧ"
<dead_stroke> <t> : "ŧ"
<dead_tilde> <U> : "Ũ"
<dead_tilde> <u> : "Å©"
<dead_macron> <U> : "Ū"
<dead_macron> <u> : "Å«"
<dead_breve> <U> : "Ŭ"
<dead_breve> <u> : "Å­"
<dead_abovering> <U> : "Å®"
<dead_abovering> <u> : "ů"
<dead_ogonek> <U> : "Ų"
<dead_ogonek> <u> : "ų"
<dead_circumflex> <W> : "Å´"
<dead_circumflex> <w> : "ŵ"
<dead_circumflex> <Y> : "Ŷ"
<dead_circumflex> <y> : "Å·"
<dead_diaeresis> <Y> : "Ÿ"
<dead_acute> <Z> : "Ź"
<dead_acute> <z> : "ź"
<dead_abovedot> <Z> : "Å»"
<dead_abovedot> <z> : "ż"
<dead_caron> <Z> : "Ž"
<dead_caron> <z> : "ž"
<dead_stroke> <b> : "Æ€"
<dead_stroke> <I> : "Æ—"
<dead_stroke> <Z> : "Ƶ"
<dead_stroke> <z> : "ƶ"
<dead_caron> <A> : "Ǎ"
<dead_caron> <a> : "ÇŽ"
<dead_caron> <I> : "Ǐ"
<dead_caron> <i> : "ǐ"
<dead_caron> <O> : "Ç‘"
<dead_caron> <o> : "Ç’"
<dead_caron> <U> : "Ç“"
<dead_caron> <u> : "Ç”"
<dead_macron> <dead_diaeresis> <U> : "Ç•"
<dead_diaeresis> <dead_macron> <U> : "Ç•"
<dead_macron> <dead_diaeresis> <u> : "Ç–"
<dead_diaeresis> <dead_macron> <u> : "Ç–"
<dead_acute> <dead_diaeresis> <U> : "Ç—"
<dead_diaeresis> <dead_acute> <U> : "Ç—"
<dead_acute> <dead_diaeresis> <u> : "ǘ"
<dead_diaeresis> <dead_acute> <u> : "ǘ"
<dead_caron> <dead_diaeresis> <U> : "Ç™"
<dead_diaeresis> <dead_caron> <U> : "Ç™"
<dead_diaeresis> <dead_caron> <u> : "Çš"
<dead_caron> <dead_diaeresis> <u> : "Çš"
<dead_grave> <dead_diaeresis> <U> : "Ç›"
<dead_diaeresis> <dead_grave> <U> : "Ç›"
<dead_grave> <dead_diaeresis> <u> : "ǜ"
<dead_diaeresis> <dead_grave> <u> : "ǜ"
<dead_diaeresis> <dead_macron> <A> : "Çž"
<dead_macron> <dead_diaeresis> <A> : "Çž"
<dead_diaeresis> <dead_macron> <a> : "ÇŸ"
<dead_macron> <dead_diaeresis> <a> : "ÇŸ"
<dead_macron> <dead_dotabove> <A> : "Ç "
<dead_dotabove> <dead_macron> <A> : "Ç "
<dead_macron> <dead_dotabove> <a> : "Ç¡"
<dead_dotabove> <dead_macron> <a> : "Ç¡"
<dead_macron> <Multi_key> <A> <E> : "Ç¢"
<dead_macron> <Multi_key> <a> <e> : "Ç£"
<dead_stroke> <G> : "Ǥ"
<dead_stroke> <g> : "Ç¥"
<dead_caron> <G> : "Ǧ"
<dead_caron> <g> : "ǧ"
<dead_caron> <K> : "Ǩ"
<dead_caron> <k> : "Ç©"
<dead_ogonek> <O> : "Ǫ"
<dead_ogonek> <o> : "Ç«"
<dead_ogonek> <dead_macron> <O> : "Ǭ"
<dead_macron> <dead_ogonek> <O> : "Ǭ"
<dead_ogonek> <dead_macron> <o> : "Ç­"
<dead_macron> <dead_ogonek> <o> : "Ç­"
<dead_caron> <j> : "Ç°"
<dead_acute> <G> : "Ç´"
<dead_acute> <g> : "ǵ"
<dead_grave> <N> : "Ǹ"
<dead_grave> <n> : "ǹ"
<dead_abovering> <dead_acute> <A> : "Ǻ"
<dead_acute> <dead_abovering> <A> : "Ǻ"
<dead_abovering> <dead_acute> <a> : "Ç»"
<dead_acute> <dead_abovering> <a> : "Ç»"
<dead_acute> <Multi_key> <A> <E> : "Ǽ"
<dead_acute> <Multi_key> <a> <e> : "ǽ"
<dead_acute> <dead_stroke> <O> : "Ǿ"
<dead_acute> <dead_stroke> <o> : "Ç¿"
<dead_grave> <dead_grave> <A> : "È€"
<dead_grave> <dead_grave> <a> : "ȁ"
<dead_grave> <dead_grave> <E> : "È„"
<dead_grave> <dead_grave> <e> : "È…"
<dead_grave> <dead_grave> <I> : "Ȉ"
<dead_grave> <dead_grave> <i> : "ȉ"
<dead_grave> <dead_grave> <O> : "Ȍ"
<dead_grave> <dead_grave> <o> : "ȍ"
<dead_grave> <dead_grave> <R> : "Ȑ"
<dead_grave> <dead_grave> <r> : "È‘"
<dead_grave> <dead_grave> <U> : "È”"
<dead_grave> <dead_grave> <u> : "È•"
<dead_caron> <H> : "Èž"
<dead_caron> <h> : "ÈŸ"
<dead_abovedot> <A> : "Ȧ"
<dead_abovedot> <a> : "ȧ"
<dead_cedilla> <E> : "Ȩ"
<dead_cedilla> <e> : "È©"
<dead_diaeresis> <dead_macron> <O> : "Ȫ"
<dead_macron> <dead_diaeresis> <O> : "Ȫ"
<dead_diaeresis> <dead_macron> <o> : "È«"
<dead_macron> <dead_diaeresis> <o> : "È«"
<dead_tilde> <dead_macron> <O> : "Ȭ"
<dead_macron> <dead_tilde> <O> : "Ȭ"
<dead_tilde> <dead_macron> <o> : "È­"
<dead_macron> <dead_tilde> <o> : "È­"
<dead_abovedot> <O> : "È®"
<dead_abovedot> <o> : "ȯ"
<dead_macron> <dead_abovedot> <O> : "È°"
<dead_abovedot> <dead_macron> <O> : "È°"
<dead_macron> <dead_abovedot> <o> : "ȱ"
<dead_abovedot> <dead_macron> <o> : "ȱ"
<dead_macron> <Y> : "Ȳ"
<dead_macron> <y> : "ȳ"
<dead_stroke> <A> : "Ⱥ"
<dead_stroke> <C> : "È»"
<dead_stroke> <c> : "ȼ"
<dead_stroke> <B> : "Ƀ"
<dead_stroke> <E> : "Ɇ"
<dead_stroke> <e> : "ɇ"
<dead_stroke> <J> : "Ɉ"
<dead_stroke> <j> : "ɉ"
<dead_stroke> <R> : "Ɍ"
<dead_stroke> <r> : "ɍ"
<dead_stroke> <Y> : "ÉŽ"
<dead_stroke> <y> : "ɏ"
<dead_caron> <space> : "ˇ"
<dead_breve> <space> : "˘"
<dead_abovedot> <space> : "Ë™"
<dead_abovering> <space> : "Ëš"
<dead_ogonek> <space> : "Ë›"
<dead_acute> <dead_acute> <space> : "˝"
<dead_abovedot> <B> : "Ḃ"
<dead_abovedot> <b> : "ḃ"
<dead_acute> <dead_cedilla> <C> : "Ḉ"
<dead_cedilla> <dead_acute> <C> : "Ḉ"
<dead_acute> <dead_cedilla> <c> : "ḉ"
<dead_cedilla> <dead_acute> <c> : "ḉ"
<dead_abovedot> <D> : "Ḋ"
<dead_abovedot> <d> : "ḋ"
<dead_cedilla> <D> : "Ḑ"
<dead_cedilla> <d> : "ḑ"
<dead_tilde> <L> : "â±¢"
<dead_stroke> <P> : "â±£"
<dead_stroke> <a> : "â±¥"
Putting this in the same place on your system may fix your problem.
shuxuef said:
So I guess it's kind of implied that there is not a 'thorough' description on the options for setxkbmap then?
Pretty much. I’ve been trying to figure it out for years.
 
Double‐posting because my last post hit the limit of 10,000 characters.
killasmurf86 said:
Now you need to find how to make it work with AltGR
Adding AltGr to a layout that doesn’t have it is difficult. The easiest way I’ve found is to create a completely new layout and assign it with xkbcomp(1). I recently did this to create a US Dvorak layout with AltGr. Rather than post the entire thing (likely to hit the 10,000 char limit again), I’ll show the steps I used to figure it out.

You can view the current keyboard layout with this:
$ xkbcomp $DISPLAY -

To figure out how AltGr worked, I ran the above after $ setxkbmap us and $ setxkbmap -layout us -variant intl and piped the results to $ diff -u to see the differences. Namely, to enable AltGr on the Right Alt key, replace the “key <RALT>” section with:
Code:
    key <RALT> {
        type= "ONE_LEVEL",
        symbols[Group1]= [ ISO_Level3_Shift ]
    };
And the difference in key combinations can be easily seen in the diff:
Code:
--- us.xkb	Sat Feb 26 21:30:21 2011
+++ us-intl.xkb	Sat Feb 26 21:30:41 2011
-  key <AE01> {   [   1,  exclam ] };
-  key <AE02> {   [   2,  at ] };
-  key <AE03> {   [   3,  numbersign ] };
-  key <AE04> {   [   4,  dollar ] };
-  key <AE05> {   [   5,   percent ] };
-  key <AE06> {   [   6,   asciicircum ] };
-  key <AE07> {   [   7,   ampersand ] };
-  key <AE08> {   [   8,  asterisk ] };
-  key <AE09> {   [   9,   parenleft ] };
-  key <AE10> {   [   0,  parenright ] };
-  key <AE11> {   [   minus,  underscore ] };
-  key <AE12> {   [   equal,  plus ] };
+  key <AE01> {
+  type= "FOUR_LEVEL",
+  symbols[Group1]= [   1,  exclam,  exclamdown,   onesuperior ]
+  };
+  key <AE02> {
+  type= "FOUR_LEVEL",
+  symbols[Group1]= [   2,  at,   twosuperior, dead_doubleacute ]
+  };
+  key <AE03> {
+  type= "FOUR_LEVEL",
+  symbols[Group1]= [   3,  numbersign,   threesuperior,   dead_macron ]
+  };
+  key <AE04> {
+  type= "FOUR_LEVEL",
+  symbols[Group1]= [   4,  dollar,  currency,  sterling ]
+  };
+  key <AE05> {
+  type= "FOUR_LEVEL",
+  symbols[Group1]= [   5,   percent,  EuroSign,  NoSymbol ]
+  };
+  key <AE06> {
+  type= "FOUR_LEVEL",
+  symbols[Group1]= [   6, dead_circumflex,  onequarter,   asciicircum ]
+  };
+  key <AE07> {
+  type= "FOUR_LEVEL",
+  symbols[Group1]= [   7,   ampersand,   onehalf,   dead_horn ]
+  };
+  key <AE08> {
+  type= "FOUR_LEVEL",
+  symbols[Group1]= [   8,  asterisk,   threequarters,   dead_ogonek ]
+  };
+  key <AE09> {
+  type= "FOUR_LEVEL",
+  symbols[Group1]= [   9,   parenleft, leftsinglequotemark,  dead_breve ]
+  };
+  key <AE10> {
+  type= "FOUR_LEVEL",
+  symbols[Group1]= [   0,  parenright, rightsinglequotemark,  dead_abovering ]
+  };
+  key <AE11> {
+  type= "FOUR_LEVEL",
+  symbols[Group1]= [   minus,  underscore,   yen,   dead_belowdot ]
+  };
+  key <AE12> {
+  type= "FOUR_LEVEL",
+  symbols[Group1]= [   equal,  plus,  multiply,  division ]
+  };
After creating this and saving it in a file (say, newlayout.xkb), you can enable it with xkbcomp:
$ xkbcomp newlayout.xkb $DISPLAY

The names of keys, like “minus,” “underscore,” and such are listed in /usr/X11R6/include/X11/keysymdef.h on my OpenBSD system, and probably a similar place in FreeBSD. You can also specify Unicode characters when they don’t have X11 names. My line for the S key does this for ß and ẞ:
Code:
    key <AC10> {
        type= "FOUR_LEVEL_SEMIALPHABETIC",
        symbols[Group1]= [ s, S, ssharp, U1E9E ]
    };
You can view my complete Dvorak‐with‐dead‐keys layout at my website.
 
Thanks, Bentley.

I was trying again to see if the '-key is working or not. And the situation turns out to be a little bit mysterious.

If after starting the computer, my first invoking of the command is "setxkbmap -layout us -variant intl", then the full functioning us-international layout is usable; everything is working. On the other hand, if after starting the machine, my first invoking of it is "setxkbmap -layout us_intl", then I can't get a full functioning us-international layout. In this case, if I switch to "-layout us -variant intl", pressing the '-key would not produce any output; and the accents are not working.

But in any case, "setxkbmap -layout us_intl" is never working fully. So I guess, as long as I keep using "-layout us -variant intl", it should be fine, as far as I observe. (But I'll keep you suggestion in mind).


Bentley said:
When you press ', does it give you an apostrophe or do nothing?

If it gives an apostrophe, I don’t know how to fix that. But doing nothing is a symptom of an incomplete compose file. X11 uses xkb to assign a dead key action like an accent to a physical key, but uses Compose(5) to assign sequences to them. So you can customize what the dead keys do that way.

...Putting this in the same place on your system may fix your problem.Pretty much. I’ve been trying to figure it out for years.
 
There is another solution: you can modify files under /usr/local/share/X11/xkb/symbols to what you need. This way I just made a Latvian US-Dvorak compatible custom keyboard layout, and as soon as I update the lv file (which stands for Latvian) there, I can switch to this new layout with setxkbmap. It was quite easy.
 
Back
Top