Bug 2189200

Summary: Setting X11 keyboard overrides console keyboard settings
Product: [Fedora] Fedora Reporter: Renaud Métrich <rmetrich>
Component: systemdAssignee: systemd-maint
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 38CC: dtardon, fedoraproject, filbranden, lnykryn, msekleta, ryncsn, systemd-maint, yuwatana, zbyszek
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-07-17 13:18:59 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Renaud Métrich 2023-04-24 12:17:47 UTC
I have a laptop with builtin US keyboard, and an external USB keyboard in FR layout used when docked.
When booting, because my disk is encrypted, I need to enter the passphrase for LUKS.

Because the keyboard I'll use depends on whether I'm docked or not, I need to be able to switch layout.
For this to happen, I use the `localectl set-keymap us fr` command then rebuilt the initramfs (this changes `/etc/vconsole.conf`).
But actually I wasn't able to test if that works yet.

Still, it appears that if I set the X11 keyboard similarly, this overrides the console layout:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
# localectl set-keymap us fr

# cat /etc/vconsole.conf 
KEYMAP=us
FONT=eurlatgr
XKBLAYOUT=us
KEYMAP_TOGGLE=fr
XKBMODEL=pc105+inet
XKBOPTIONS=terminate:ctrl_alt_bksp
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

Here above, XKBLAYOUT is now "us" only.

-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
# localectl set-x11-keymap us,fr

# cat /etc/vconsole.conf 
KEYMAP=us
FONT=eurlatgr
XKBLAYOUT=us,fr
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

Here above, XKBLAYOUT is now "us,fr" but console's KEYMAP_TOGGLE vanished.

The only way I found to avoid overriding the settings is to first use "set-x11-keymap" then "set-keymap --no-convert":

-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
# localectl set-x11-keymap us,fr
--> breaks console keyboard

# localectl set-keymap us fr --no-convert 
--> sets back console keyboard without modifying X11 keyboard
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

IMHO neither "set-keymap" nor "set-x11-keymap" should modify the other's console settings.

Reproducible: Always

Steps to Reproduce:
Setup a system with 2 keyboards

Comment 1 David Tardon 2023-05-17 14:30:51 UTC
(In reply to Renaud Métrich from comment #0)
> IMHO neither "set-keymap" nor "set-x11-keymap" should modify the other's
> console settings.

No, that's intentional and documented behavior. We want the settings to be in sync.

Comment 2 Zbigniew Jędrzejewski-Szmek 2023-07-17 13:18:59 UTC
Yeah, keeping both in sync is the expected behaviour. If you need something
different, it's OK to write some special configuration, but the automation
provided by localed works like it does, and we want to keep it this way. It's
the right thing for 99% of users.