Centos 7 - layout de teclado personalizado através do terminal

1

Estou usando o CentOS 7 sem GUI. Como posso criar um layout de teclado personalizado e usá-lo como padrão permanentemente? Qual arquivo devo editar?

EDITAR:

Eu consigo trabalhar na GUI, configurando keymaps editando arquivos em /usr/share/X11/xkb/symbols e reinicializando, mas isso não está afetando o terminal (pelo menos não o que eu inicio com Ctrl+Alt+F5 . Nesse terminal, eu ainda uso os EUA O terminal de inicialização sob o GNOME usa meu layout.

Eu coloquei meus arquivos de mapa de teclado em /lib/kbd/keymaps/legacy/i386/xxx/ as xxx.map.gz , e ele realmente carrega bem com loadkeys , e quando eu corro localectl eu vejo:

# localectl
System Locale: LANG=en_US.UTF-8
   VC Keymap: xxx
  X11 Layout: us

Mas no terminal aberto com Ctrl + Alt + F5, o layout do teclado é o antigo.

    
por WesternGun 19.10.2017 / 11:35

2 respostas

2

Para começar com a configuração existente:

  • O layout atual do teclado pode ser descartado usando dumpkeys .
  • Outros layouts padrão estão disponíveis geralmente abaixo do diretório / lib / kbd / keymaps como arquivos gzipados, use zcat ou zless para acessar facilmente seu conteúdo.

Para obter o código de algumas das suas teclas do teclado, use showkey .

Para carregar manualmente um arquivo de layout de teclado, use loadkeys . Aceita o caminho para um arquivo personalizado como parâmetro.

Quando estiver satisfeito com o resultado, você pode definir o nome do novo layout para usar por padrão em /etc/vconsole.conf :

KEYMAP="your-layout"
    
por 26.10.2017 / 12:03
0

Apenas para adicionar alguns detalhes da resposta aceita, aqui está o que eu vejo e o que eu fiz para fazê-lo funcionar; irá adicionar mais truques e reviravoltas se eu os encontrar.

Usar sudo dumpkeys fornecerá a saída assim:

keycode  12 = minus
    shift   keycode  12 = underscore
    shift   altgr   keycode  12 = underscore
    control keycode  12 = Control_underscore
    shift   control keycode  12 = Control_underscore
    altgr   control keycode  12 = Control_underscore
    shift   altgr   control keycode  12 = Control_underscore
    alt     keycode  12 = Meta_minus
    ...

E, se você abrir os arquivos de mapa de teclado em /lib/kbd/keymaps/xkb/ , verá que em uma linha há várias colunas (às vezes muitas) como:

keycode 12 = U+002d U+005f U+002d U+005f Control_underscore Control_underscore Control_underscore ...

De acordo com a página do manual de keymaps : ( man 5 keymaps ), temos:

Which of the actions bound to a given key is taken when it is pressed depends on what modifiers are in effect at that moment. The keyboard driver supports 9 modifiers. These modifiers are labeled (completely arbitrarily) Shift, AltGr, Control, Alt, ShiftL, ShiftR, CtrlL, CtrlR and CapsShift. Each of these modifiers has an associated weight of power of two according to the following table:

modifier   weight
Shift           1
AltGr           2
Control         4
Alt             8
ShiftL         16
ShiftR         32
CtrlL          64
CtrlR         128
CapsShift     256

The effective action of a key is found out by adding up the weights of all the modifiers in effect. By default, no modifiers are in effect, so action number zero, i.e. the one in the first column in a key definition line, is taken when the key is pressed or released. When e.g. Shift and Alt modifiers are in effect, action number nine (from the 10th column) is the effective one.

Changing the state of what modifiers are in effect can be achieved by binding appropriate key actions to desired keys. For example, binding the symbol Shift to a key sets the Shift modifier in effect when that key is pressed and cancels the effect of that modifier when the key is released. Binding AltGr_Lock to a key sets AltGr in effect when the key is pressed and cancels the effect when the key is pressed again. (By default Shift, AltGr, Control and Alt are bound to the keys that bear a similar label; AltGr may denote the right Alt key.)

E sabemos que U+002d é Hyphen-Minus e U+005f é low-line , então agora a vemos clara: cada linha no arquivo keymap, é o código-chave e seus caracteres keys emitidos quando a própria chave, deslocar + tecla, shift + altgr + tecla, ... é pressionada, nessa ordem.

(Caso você esqueça a tabela, podemos usar dumpkeys --long-info para mostrá-la).

Eles correspondem um ao outro: as linhas na primeira parte correspondem às colunas na segunda parte .

Melhor visualizá-lo em uma tabela:

+----------+------------------------+----------------------------+
|          |                        |                            |
|  col.    | key to press(+ keycode)| chars to produce (keysys)  |
|          |                        |                            |
+----------------------------------------------------------------+
|          |                        |                            |
|   0      | keycode 12             | minus                      |
|          |                        |                            |
+----------------------------------------------------------------+
|          |                        |                            |
|   1      | shift                  | underscore                 |
|          |                        |                            |
+----------------------------------------------------------------+
|          |                        |                            |
|   2      | altgr                  | underscore                 |
|          |                        |                            |
+----------------------------------------------------------------+
|          |                        |                            |
|   3(1+2) | shift + altgr          | underscore                 |
|          |                        |                            |
+----------------------------------------------------------------+
|          |                        |                            |
|   4      | ctrl                   | ctrl + underscore          |
|          |                        |                            |
+----------------------------------------------------------------+
|          |                        |                            |
|   5(4+1) | ctrl + shift           | ctrl + underscore          |
|          |                        |                            |
+----------+------------------------+----------------------------+
|          |                        |                            |
|   6(4+2) | ctrl + alt             | ctrl + underscore          |
|          |                        |                            |
+----------+------------------------+----------------------------+
    
por 28.01.2018 / 22:45