2

I use setxkbmap dk.

I need the alt gr + j combination mapped to a character that isn't already included in the layout. At the moment, alt gr + j maps to nothing.

The reason why I want to do this is so that I can map the character code (of whatever character alt gr+j produces) to something in vim, using this technique.

1 Answers1

2

the quick way would be modifying the/usr/share/X11/xkb/symbols/dk file, while the more complex would be creating a new layout and not mess too much with these default files.

you can add the your customization in the dk file such as:

default  partial alphanumeric_keys
xkb_symbols "basic" {
include "latin(type2)"

name[Group1]="Danish";

key <AE11>  { [      plus,   question,    plusminus, questiondown ] };
key <AE12>  { [dead_acute, dead_grave,          bar,    brokenbar ] };

key <AC10>  { [        ae,        AE,   dead_acute, dead_doubleacute ] };
key <AC11>  { [    oslash,  Ooblique, dead_circumflex, dead_caron ] };
key <TLDE>  { [   onehalf,   section, threequarters,    paragraph ] };

key <BKSL>  { [apostrophe,   asterisk, dead_doubleacute, multiply ] };

key <LSGT>  { [      less,    greater,    backslash,      notsign ] };

// customization
key <AC07>  { [         j,          J,    VoidSymbol, VoidSymbol  ] };
// end of customization


include "kpdl(comma)"

include "level3(ralt_switch)"

};

change VoidSymbol for the symbols you want to get. For a list of symbols, look here

if you are going to include more customization, you can follow the same structure as those files found in /usr/share/X11/xkb/symbols by:

  1. create a new file such as cust
  2. create a partial definition such as
partial alphanumeric_keys xkb_symbols "vim" {

// add your customization here

};

  1. in the dk file (or in your custom file if you start one from scratch) add
include "cust(vim)"

as you probably realized, you can do in different ways. the "recommended is to create from scratch and leave the default ones unmodified (they might get, overwritten in a system update, for example). I personally prefer to create a custom files and "include" in the default files because it is easier, for example, to find and change layouts using e.g. gnome settings. And, in case the file gets overwritten, i just need to add "include x(y)" and it is all set...