Jan Čermák 0354f47ecf
Make console keymaps configurable through localectl (#4424)
For users having non-English, and especially non-qwerty layouts, using the host
shell can be very awkward. There was no option to change the keymaps as they
haven't been installed in the OS, and the persistence couldn't have been
achieved because of read-only /etc.

With upstream patch merged in #4224, we have an option to put
/etc/vconsole.conf to a writable location and use the same approach as in the
timezone PR. This is needed because even if we only bind-mounted the file from
the overlay directory, the Systemd services which start early will still refer
to the inode on the read-only FS. Also, gzip is required as current version of
kbd in Buildroot (v2.6.4) always compresses the keymaps using gzip. We can get
rid of this after we bump to kbd v2.9.0 [1] or newer. The overall bloat in
local build of the OS is slightly over 1 MiB, so it is acceptable.

With these changes, the `localectl set-keymap` command can be used to use any
available keymap from the installed `kbd` package (refer to `localectl
list-keymaps` for complete lists) and persist it between reboots.

[1] https://github.com/legionus/kbd/releases/tag/v2.9.0

Fixes #1775
2025-12-02 17:20:28 +01:00

30 lines
720 B
Bash
Executable File

#!/bin/sh
mkdir -p /mnt/overlay/etc/
# Network
mkdir -p /mnt/overlay/etc/NetworkManager/system-connections
if [ ! -f /mnt/overlay/etc/hostname ]; then
cp -fp /etc/hostname /mnt/overlay/etc/hostname
fi
if [ ! -f /mnt/overlay/etc/hosts ]; then
cp -fp /etc/hosts /mnt/overlay/etc/hosts
fi
# TimeSync
if [ ! -f /mnt/overlay/etc/systemd/timesyncd.conf ]; then
mkdir -p /mnt/overlay/etc/systemd
cp -fp /etc/systemd/timesyncd.conf /mnt/overlay/etc/systemd/timesyncd.conf
fi
if [ ! -L /mnt/overlay/etc/localtime ]; then
ln -sf /usr/share/zoneinfo/Etc/UTC /mnt/overlay/etc/localtime
fi
# Console
if [ ! -f /mnt/overlay/etc/vconsole.conf ]; then
echo "KEYMAP=us" > /mnt/overlay/etc/vconsole.conf
fi