# setxkbmap manual



## shuxuef (Feb 21, 2011)

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!


----------



## graudeejs (Feb 21, 2011)

What lang do you want to switch?
here's what I use

```
# Latvian native lang with AltGr
setxkbmap lv
# Russian phonetic
setxkbmap ru phonetic
# Russian
setxkbmap ru
# Latvian with apostrophe
setxkbmap lv apostrophe
```


----------



## shuxuef (Feb 22, 2011)

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
> 
> ```
> ...


----------



## captobvious (Feb 22, 2011)

http://www.freebsd.org/cgi/man.cgi?query=setxkbmap&sektion=1&manpath=X11R7.4

This might work, but I havent tried it (I switch between setxkbmap dvorak/us)

setxkbmap -model pc102 -layout us_intl


----------



## graudeejs (Feb 22, 2011)

shuxuef said:
			
		

> Well, like I said, mostly I just want to use the us-international layout; specifically, it's for French.



I found this

```
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


----------



## shuxuef (Feb 22, 2011)

So I guess it's kind of implied that there is not a 'thorough' description on the options for setxkbmap then?


----------



## Bentley (Feb 27, 2011)

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:
	
	



```
<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.


----------



## Bentley (Feb 27, 2011)

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:
	
	



```
key <RALT> {
        type= "ONE_LEVEL",
        symbols[Group1]= [ ISO_Level3_Shift ]
    };
```
And the difference in key combinations can be easily seen in the diff:
	
	



```
--- 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 áºž:
	
	



```
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.


----------



## shuxuef (Feb 27, 2011)

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.


----------



## graudeejs (Apr 9, 2011)

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.


----------

