Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way from command line to retrieve the list of all available keyboard layouts and relative variants?

I need to list all the valid layout/variants choices to be used then from setxkbmap.

Also about the layout toggle options, is there a way to retrieve a list of all available choices (e.g. grp:shift_caps_toggle , ...)

I know that with

setxkbmap -query

I retrieve the list of my current ones, but I need the whole list of options.


I've been told about the command

man xkeyboard-config

which provides all the info to the command line.

Furthermore, using

man -P cat xkeyboard-config

the output goes to stdout and can be parsed with scripts or c code

share|improve this question
up vote 8 down vote accepted

Try looking in /usr/share/X11/xkb/symbols as described on the setxkbmap man page. The options can be found in various files, try doing a grep -rinH alts_toggle /usr/share/X11/xkb. /usr/share/X11/xkb/rules/xorg.xml looks like a good choice.

share|improve this answer
you were of great help, I understood how to get the layouts and the toggle options but still did not get how to retrieve the variants names to be inserted in setxkbmap. – giuspen Jul 25 '12 at 21:51
the variants are defined seperately for each layout. for example, you can use grep -E ^xkb_symbols < /usr/share/X11/xkb/symbols/dk to view the variants of the Danish layout. If you need reliable parsing, you probably need to look in the XKB sources. – Janus Troelsen Jul 25 '12 at 21:59
I got it, reading the files in the folder /usr/share/X11/xkb/symbols and searching for the lines like xkb_symbols "de" where "de" is a variant of /usr/share/X11/xkb/symbols/ch – giuspen Jul 25 '12 at 21:59
great help, thank you very much. – giuspen Jul 25 '12 at 22:00
I've been told about the useful command "man xkeyboard-config", pity that cannot parse the output from a script or c code since there's not an equivalent --help. – giuspen Jul 27 '12 at 11:16

There is a related question on askubuntu that links to a list of all these keyboard layouts.

share|improve this answer
Can you edit the link to the question please, as I believe the pastebin will expire. – eyoung100 Sep 11 '14 at 20:43
Sorry I updated the link. And the pastebin is set to never expire. – Vince Sep 11 '14 at 21:28
Great, Thank You. – eyoung100 Sep 11 '14 at 21:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.