Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

[SOLVED]Changing keyboard layout in console

Linux Kernel, Network, and Services configuration.
Post Reply
Message
Author
pythagorasmk
Posts: 148
Joined: 2015-01-18 03:40
Been thanked: 2 times

[SOLVED]Changing keyboard layout in console

#1 Post by pythagorasmk »

Is it possible to have multiply keyboard layouts in console and to have key combination to switch between them?
Last edited by pythagorasmk on 2020-02-13 18:19, edited 1 time in total.

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 133 times

Re: Changing keyboard layout in console

#2 Post by Head_on_a_Stick »

Not really (AFAIK), but you can use localectl(1) to change console keyboard layout.

Perhaps if you ran dvtm (or plain tmux) from the console you could bind keys calling that command.

EDIT: corrected command name.
Last edited by Head_on_a_Stick on 2020-02-12 17:09, edited 1 time in total.
deadbang

User avatar
fabien
Forum Helper
Forum Helper
Posts: 664
Joined: 2019-12-03 12:51
Location: Anarres (Toulouse, France actually)
Has thanked: 61 times
Been thanked: 153 times

Re: Changing keyboard layout in console

#3 Post by fabien »

It is possible to use loadkeys(1) to change keyboard layout on the fly (i.e. without changing system configuration):

- package console-data must be installed

- you have to allow your user to use loadkeys (see https://unix.stackexchange.com/question ... ormal-user)

- there may be security concerns (that's why loadkeys doesn't work if not setuid, see https://git.kernel.org/pub/scm/linux/ke ... c4b8871968) so all in all be aware that it might not be good practice.

pythagorasmk
Posts: 148
Joined: 2015-01-18 03:40
Been thanked: 2 times

Re: Changing keyboard layout in console

#4 Post by pythagorasmk »

I am giving up, security risk + to complicated, not for me. Anyway Thanks for the answer.

pythagorasmk
Posts: 148
Joined: 2015-01-18 03:40
Been thanked: 2 times

Re: Changing keyboard layout in console

#5 Post by pythagorasmk »

fabien wrote:It is possible to use loadkeys(1) to change keyboard layout on the fly (i.e. without changing system configuration):
I have found package console-setup and with it you can have the same options for keyboard on console, as in Xserver. The default configuration is located in /etc/default/keyboard. Read keyboard(5).

User avatar
fabien
Forum Helper
Forum Helper
Posts: 664
Joined: 2019-12-03 12:51
Location: Anarres (Toulouse, France actually)
Has thanked: 61 times
Been thanked: 153 times

Re: [SOLVED]Changing keyboard layout in console

#6 Post by fabien »

This is the right solution, thanks pythagorasmk. The loadkeys method is definitely to be forgotten then (it was an old remembrance btw, something I used long ago).

Here is the documentation on Debian Wiki: https://wiki.debian.org/Keyboard

Code: Select all

man 7 xkeyboard-config
is useful to find some configuration elements (layouts, switches) for /etc/default/keyboard.

In short:
- edit /etc/default/keyboard. For example:

Code: Select all

# KEYBOARD CONFIGURATION FILE

# Consult the keyboard(5) manual page. man xkeyboard-config(7) also.

XKBMODEL="pc105"
XKBLAYOUT="fr,us"
XKBVARIANT="latin9,"
XKBOPTIONS="grp:alts_toggle"

BACKSPACE="guess"
this configuration allows to switch between french and US layouts by striking alt and altgr together.

- from the console, test the configuration:

Code: Select all

setupcon
- make changes permanent (this part is not on the Debian Wiki but it is the only way that worked for me):

Code: Select all

dpkg-reconfigure console-setup

pythagorasmk
Posts: 148
Joined: 2015-01-18 03:40
Been thanked: 2 times

Re: [SOLVED]Changing keyboard layout in console

#7 Post by pythagorasmk »

fabien wrote: - make changes permanent (this part is not on the Debian Wiki but it is the only way that worked for me):

Code: Select all

dpkg-reconfigure console-setup
You can edit the file /etc/default/console-setup directly, there is no need for dpkg-reconfigure console-setup. Read console-setup(5).
The only limitation for me is that accented letters in Macedonian alphabet ( ѐ and ѝ ) and the symbol for euro € are missing in fonts for console.
Also, if you are using Emacs, it is not smart to use left alt + left shift (standard Windows combination ) for switch key, I have assigned this function to ScrollLock.

User avatar
fabien
Forum Helper
Forum Helper
Posts: 664
Joined: 2019-12-03 12:51
Location: Anarres (Toulouse, France actually)
Has thanked: 61 times
Been thanked: 153 times

Re: [SOLVED]Changing keyboard layout in console

#8 Post by fabien »

pythagorasmk wrote:You can edit the file /etc/default/console-setup directly, there is no need for dpkg-reconfigure console-setup. Read console-setup(5).
dpkg-reconfigure console-setup is the way I found to make changes permanent, otherwise changes were lost upon reboot (I'm on Buster). Have you done something else to keep changes effective?
I know I can edit /etc/default/console-setup directly, I added BEEP="polite" to it to no avail until I run dpkg-reconfigure console-setup. There should be a smarter way though, I agree.
pythagorasmk wrote: it is not smart to use left alt + left shift
I use alt+altgr in the example above, but that's up to the user (man 7 xkeyboard-config for a list of available switches).
pythagorasmk wrote:( ѐ and ѝ ) and the symbol for euro € are missing
take a look at section 'Adding currency signs to certain keys' in man 7 xkeyboard-config maybe. For the Macedonian alphabet I have no clue.

pythagorasmk
Posts: 148
Joined: 2015-01-18 03:40
Been thanked: 2 times

Re: [SOLVED]Changing keyboard layout in console

#9 Post by pythagorasmk »

fabien wrote: dpkg-reconfigure console-setup is the way I found to make changes permanent, otherwise changes were lost upon reboot (I'm on Buster). Have you done something else to keep changes effective?
For me everything is working fine, I have edited the console-setup with emacs, saved the file, rebooted the system and everything is working fine. I am also on Debian Buster.
fabien wrote: I use alt+altgr in the example above, but that's up to the user (man 7 xkeyboard-config for a list of available switches).
Yes it is up to the user, but left alt+left shift is useful combination in Emacs.
fabian wrote: take a look at section 'Adding currency signs to certain keys' in man 7 xkeyboard-config maybe. For the Macedonian alphabet I have no clue.
Yes, I can add the euro sign to some key, but I have to use 3-level chooser, which cannot be pause, scroll lock or prtscr and I don't want to use ctrl or alt for that. I can live with that. It is interesting that I can get euro sign in Xserver with Compose key and after that e and =, but this combination is not working in console, and I don't know why? For macedonian symbols, I think that they are missing in fonts files for console, because the deadkey is working in console. I think that this is a long time bug, and nobody is taking care of it.
It is interesting that PtrScr is not working as a compose key in console, but it is working in Xserver. I don't know why? I think this is a bug.

Post Reply