2

The devices I work with and develop on are made by a Danish company. Whenever we ssh into into the Debian 8 based devices, they keyboard layout is US QWERTY, but if we attach a US USB keyboard to the device itself, they keyboard layout is Danish.

I've been trying to find a simple way to set the keyboard layout across all 10 virtual terminals, as we use them for development purposes. (They are a mingetty run by a systemd service on boot).

I've found that I can somewhat successfully change the layout to US if I:

  • Am SSH'd into the device
  • Edit /etc/default/keyboard manually to have XKBLAYOUT="us" instead of XKBLAYOUT="dk"
  • Run udevadm trigger --subsystem-match=input --action=change

However, it didn't change the layout for Virtual Terminals that I then log into locally afterward.

I can successfully change the layout to US for all VTs if I:

  • Am SSH'd into the device or am logged in locally
  • Edit /etc/default/keyboard manually to have XKBLAYOUT="us" instead of XKBLAYOUT="dk"
  • Reboot the device

Is there any other way to get these changes to stick without having to restart the whole device?

I know that all I need to do is change the XKBLAYOUT so when I've tried using setxkbmap -model pc105 -layout us I get back Cannot open display "default display" back. Note: When I ssh or locally login to the device I am root, and have been running all commands as root.

My /etc/default/keyboard file is very simple:

# KEYBOARD CONFIGURATION FILE

# Consult the keyboard(5) manual page.

XKBMODEL="pc105"
XKBLAYOUT="dk"
XKBVARIANT=""
XKBOPTIONS=""

BACKSPACE="guess"

My goal is to script the process so all QA has to do is run a simple script to change back and fourth between US (So they can type more easily) and Danish (So they can set the device back to be as similar to production devices as possible).

  • Did you "consult the keyboard(5) manual page"? It says: "In order to activate the changes on the console, run setupcon(1)." – Ferenc Wágner Jun 13 at 17:23
  • I had seen it but didn't think to use it because we do run some apps via X and according to this site it said that you need to run udevadm trigger --subsystem-match=input --action=change to apply the change for X. I thought it wouldn't work for me, but it does. (at least for all the non X terminals). – Wimateeka Jun 13 at 17:34
  • Are you running X applications remotely, or are you running them on an X server on the device itself? – Stephen Kitt Jun 13 at 18:27
  • @StephenKitt The X server is running locally on the device. – Wimateeka Jun 13 at 19:42
2

On Debian, to set up the keyboard (and font) on VTs not running X, you should run setupcon. To reconfigure the default keyboard, and set it up, you should run dpkg-reconfigure keyboard-configuration.

setupcon can use multiple variants of its configuration files, which would allow you to quickly switch between keyboard layouts.

The system’s keyboard configuration has no impact on the mappings used over SSH: SSH doesn’t transmit keystrokes, it transmits characters, there is no keyboard-style mapping involved.

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.