I have a keymap file with this content:

xkb_keymap {
    xkb_keycodes  { include "evdev+aliases(qwerty)" };
    xkb_types     { include "complete+numpad(shift3)"   };
    xkb_compat    { include "complete"  };
    xkb_symbols   { include "macintosh_vndr/apple(alukbd)+macintosh_vndr/us+inet(evdev)+altwin(swap_alt_win)+capslock(backspace)+compose(rctrl)+macintosh_vndr/apple(alupckeys)+shift(both_capslock)"   };
    xkb_geometry  { include "macintosh(applealu_ansi)"  };

I thought I can load it with setxkbmap -config keymap, but I can't.

How are you supposed to use '-config'? How to load a xkb_keymap section?

Edit: I know that I can load it with xkbcomp keymap :0, but still: how does '-config' work?

Edit2: That's the output I get:

$ setxkbmap -v 10 -config ~/xkb/keymap 
Setting verbose level to 10
locale is C
Found file /home/user/xkb/keymap
Couldn't find configuration file "/home/user/xkb/keymap"

2 Answers 2

-config file
       Specifies the name of an XKB configuration
       file which describes the keyboard to be used.

I think this dates back from the time of xf86cfg. When starting X on multiple VTs one could have different keyboard configurations with per-server keyboard config files:


A keyboard configuration file consists of key = value pairs, one per line. Here is my rather simple test file, /home/don/my-config.keyboard:

Rules    =  "xorg"
Model    =  "pc104"
Layout   =  "fr"
Variant  =  "dvorak"
Options  =  "grp:caps_toggle,grp_led:caps" 

load it with setxkbmap:

setxkbmap -config /home/don/my-config.keyboard

and voilà:

setxkbmap -query


rules:      xorg
model:      pc104
layout:     fr
variant:    dvorak
options:    grp:caps_toggle,grp_led:caps
  • When running from command-line, we can give setxkbmap -option to reset all options set before. How can I achieve this in the configuration file? I tried giving just Options = and Options = "". The former throws an error and the latter doesn't work.
    – Hashken
    Apr 9, 2015 at 23:37
  • @Hashken - I don't think the config file could reset the configuration to default. It's purpose is to load a keyboard configuration and that's all it does. However, if you load a config file after another one then yes, the options in the second file will not overwrite the old ones but will be added to the existing ones. I guess one way to avoid that would be to prepend your options with a comma e.g. Options = ",grp:alt_shift_toggle" or use Options = "," to delete the old ones and load none. Apr 10, 2015 at 0:10
  • Hmm.. Makes sense. I also tried having several Options lines so as to have one setting per line. This is pretty useful to have comments on the side explaining the function. But unfortunately, if multiple Options line are given, only the last seems to take effect. Is there a way to give different Options in different lines? Also, where I can refer for the complete format of this configuration file?
    – Hashken
    Apr 10, 2015 at 1:07
  • @Hashken - the only documentation that I know of is this page Apr 10, 2015 at 8:49

The literal answer is the accepted one. This answers: How do I best load my own XKB configuration?

xkbcomp -I$HOME/xkb ~/xkb/keymap $DISPLAY

The keymap file is in the format of the OP (i.e. me). In ~/xkb I have subdirectories like keycodes and symbols which contain the extra files I references in keymap.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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