Switching Keyboard Layout. SOS

Hi Gents,

I'm sure, I wasn't searching hard enough and that's why I didn't find any way to add a second keyboard layout to the VT-console with the ability to switch between them. I'm talking specifically about the VT-console, please, keep in mind, I have NO ANY kind of X-systems. It's absolutely not necessary to change any keymaps for me. Just add another one as is and switch between them. Probably on FreeBSD there is a way like /etc/default/keyboard - file on Linux? I gave up. Please help.

Thank you.

Regards,
AS
 
Or simply create scripts (or alias) to invoke kbdcontrol to switch layout.

Just for a hint (wouldn't directly fit for your purpose, I guess). I have some codes as below to auto-select keyboard layout on boot in my /etc/rc.conf.

sh:
if [ "vt" = `sysctl -n -q kern.vty` ]
then
  keymap="jp.kbd"
  if [ -r /usr/share/vt/fonts/b16.fnt ] ; then
#    vidcontrol -f /usr/share/vt/fonts/b16.fnt
    allscreens_flags="-f /usr/share/vt/fonts/b16.fnt"
  fi
else
  keymap="jp.106.kbd"
fi

This is a kind of remnant now. I added this when I was investivating early vt driver and needed to switch within vt and sc very often. For Japanese 106 layout (OADG106), sc used jp.106.kbd but vt used jp.kbd. Almost equivalent but different in name.

Not 100% sure, but if you want switching the layout only when specific keyboard is attached, you would be able to hook devd for attach and detach to trigger switching the layout.
 
I would have suggested aliases in the global login shells configuration file ( /etc/profile , /etc/csh.cshrc ).

i.e. /etc/profile
Code:
alias  klus="kbdcontrol -l us"
alias  klfr="kbdcontrol -l fr"
All keybord maps under /usr/share/vt/keymaps.
 
I would have suggested aliases in the global login shells configuration file ( /etc/profile , /etc/csh.cshrc ).

i.e. /etc/profile
Code:
alias  klus="kbdcontrol -l us"
alias  klfr="kbdcontrol -l fr"
All keybord maps under /usr/share/vt/keymaps.
Hm..... maybe this is the way out.
Thank you, T-Daemon. I'll try it out.
 
Or simply create scripts (or alias) to invoke kbdcontrol to switch layout.

Just for a hint (wouldn't directly fit for your purpose, I guess). I have some codes as below to auto-select keyboard layout on boot in my /etc/rc.conf.

sh:
if [ "vt" = `sysctl -n -q kern.vty` ]
then
  keymap="jp.kbd"
  if [ -r /usr/share/vt/fonts/b16.fnt ] ; then
#    vidcontrol -f /usr/share/vt/fonts/b16.fnt
    allscreens_flags="-f /usr/share/vt/fonts/b16.fnt"
  fi
else
  keymap="jp.106.kbd"
fi

This is a kind of remnant now. I added this when I was investivating early vt driver and needed to switch within vt and sc very often. For Japanese 106 layout (OADG106), sc used jp.106.kbd but vt used jp.kbd. Almost equivalent but different in name.

Not 100% sure, but if you want switching the layout only when specific keyboard is attached, you would be able to hook devd for attach and detach to trigger switching the layout.
Thank you, T-Aoki.
I'm afraid it's a little bit more complicated, I expect.
 
Yes. Usually, T-Daemon's idea (or variants for other shells) shoule be better if you don't hesitate to type a command to switch.
My examples are just some small hints for automated way.
Yeah, Yeah. I got it. Thank you. But I have to press a key combination in any way.
 
I would have suggested aliases in the global login shells configuration file ( /etc/profile , /etc/csh.cshrc ).

i.e. /etc/profile
Code:
alias  klus="kbdcontrol -l us"
alias  klfr="kbdcontrol -l fr"
All keybord maps under /usr/share/vt/keymaps.
"It's sad, so sad, it's so sad, sad, situation
And it's getting more and more adsurde"

Doesn't work for me. Still "us" layout is one and only.
 
Doesn't work for me. Still "us" layout is one and only.
When you say it "doesn't work" I suspect you didn't edit the correct login shell configuration file.

What I suggested works just fine on all my systems, provided the correct shell configuration file was edited.

The example I gave (/etc/profile) is for sh(1), shells/zsh, and all other shells reading from /etc/profile.

Depending on you login shell, the system wide configuration file can differ, especially third party shells from packages. Consult the shells manual FILES section, or shell specific documentation.

Examples:

shells/bash reads from /usr/local/etc/profile

shells/fish from /usr/local/etc/fish/config.fish

tcsh(1) / csh(1) reads from /etc/csh.cshrc and the alias syntax is different.
Code:
alias  klfr kbdcontrol -l fr
Note the missing equal sign and double quotes.

If not done, the new aliases, set in a system wide configuration file, to take effect, you need to log out and log in again, execute alias to check.

If a system wide configuration is not necessary, put it in the users $HOME login shells configuration file.
 
Oh my... It was really simple, as it turned out. No any "kldcontrol", no any aliases, nothing. Just "keymap" option in rc.conf.
That's it. So, now the only thing left is to find out a way to change the key combination switching keyboard layouts, and I'm happy with it.
 
No any "kldcontrol", no any aliases, nothing. Just "keymap" option in rc.conf.
That's it. So, now the only thing left is to find out a way to change the key combination switching keyboard layouts,
There is no key combination switching keyboard layouts between system default "us" and whatever is set /etc/rc.conf keymap= on the fly without kbdcontrol -l <value> (conveniently as an alias).

But you are welcome to prove us wrong. Perhaps you find a key combination we are not aware of.
 
There is no key combination switching keyboard layouts between system default "us" and whatever is set /etc/rc.conf keymap= on the fly without kldcontrol -l <value> (conveniently as an alias).

But you are welcome to prove us wrong. Perhaps you find a key combination we are not aware of.
What kind of proof would you like to get? I'm not sure about all keymaps of course, but for ru.win.kbd it's ctrl+shift, for ru.kbd - caps.
 
First, I want to apologize. I overreacted with the last sentence in comment #14.

I'm not sure about all keymaps of course, but for ru.win.kbd it's ctrl+shift, for ru.kbd - caps.
I don't understand. We are talking about switching keyboard layouts in the vt(4) console during system operations (on the fly).

Are you saying you have configured keyboard shortcuts to switch keyboard layouts in the console (not kbdcontrol(1), no aliases)? There are certainly none by default.

If that's the case, how did you configure "ru.win.kbd ... ctrl+shift, ... ru.kbd - caps"?

Or are you referring to something else?
 
Absolutely no interference with any configuration of any files. Just a few letters in rc.conf:
keymap="ru.win"
Thats's all.
And I have two accessible layouts, "ru" and "us", that can be switched on the fly by just pressing old, good ctrl+shift
 
There are actually kbdmap(5) definitions that allow you to switch between different layouts by pressing a key combination, e. g. /usr/share/vt/keymaps/cz.kbd and /usr/share/vt/keymaps/gr.kbd use alta (AltGr lock) so mappings are looked up at +ALTGR_OFFSET (128) down in the table; thus you can switch between Czech/Hungarian and English keyboard layouts without invoking kbdcontrol(1).​

PSA: If you have not already, do yourself a favor and learn an ergonomically optimized keyboard layout such as NEO (kbdmap file), unless you do indeed use actual typewriters.
 
There are actually kbdmap(5) definitions that allow you to switch between different layouts by pressing a key combination, e. g. /usr/share/vt/keymaps/cz.kbd and /usr/share/vt/keymaps/gr.kbd use alta (AltGr lock) so mappings are looked up at +ALTGR_OFFSET (128) down in the table; thus you can switch between Czech/Hungarian and English keyboard layouts without invoking kbdcontrol(1).

PSA: If you have not already, do yourself a favor and learn an ergonomically optimized keyboard layout such as NEO (kbdmap file), unless you do indeed use actual typewriters.
Unfortunately, not all keymap has the functionality.
For example, see /usr/share/vt/keymaps/jp.kbd.
But if it is supported for every wanted keymaps, it seems to be helpful.
 
Back
Top