QubesOS / qubes-issues

The Qubes OS Project issue tracker
https://www.qubes-os.org/doc/issue-tracking/
536 stars 47 forks source link

Keyboard layout changes don't propagate from dom0 #1396

Open hdevalence opened 8 years ago

hdevalence commented 8 years ago

When the keyboard layout is changed in dom0 (e.g., using the KDE layout switcher in the icon tray) the change doesn't propagate to other VMs, in particular any VM you would actually be using.

This makes it basically impossible to (e.g., temporarily) change keyboard layouts from your default, since you have to go to every VM and manually reconfigure their input methods, and then do it all over again to change back.

marmarek commented 2 years ago

The layout switching involves several parts:

  1. qvm-start-daemon monitors _XKB_RULES_NAMES and XKLAVIER_ALLOW_SECONDARY properties on the root window ( you can check with xev -root -event property if they change)
  2. Then, it adjusts keyboard_layout property on dom0 (check with qvm-prefs dom0 keyboard_layout)
  3. Then, it's transferred using qubesdb to relevant VMs, where qubes-keymap.sh script should monitor it and apply the change (check process list in the VM to see if it runs)
holiman commented 2 years ago

Interesting!

As far as I can tell, it's 1) which is failing. If I switch layout, then indeed it works in dom0, but the qvm-prefs dom0 keyboard_layout does not change. The xev -root -event property only reacts when the cursor moves from one application screen to another.

At this point, I exited i3, and started an xfce session instead. In xcfe, the xev -root -event property did emit XKLAVIER_ALLOW_SECONDARY events, which updated the qvm-prefs, and the whole chain worked.

jamke commented 1 year ago

The layout switching involves several parts:

1. `qvm-start-daemon` monitors `_XKB_RULES_NAMES` and `XKLAVIER_ALLOW_SECONDARY` properties on the root window ( you can check with `xev -root -event property` if they change)

2. Then, it adjusts `keyboard_layout` property on dom0 (check with `qvm-prefs dom0 keyboard_layout`)

3. Then, it's transferred using qubesdb to relevant VMs, where `qubes-keymap.sh` script should monitor it and apply the change (check process list in the VM to see if it runs)

@marmarek Thank you for this valuable piece of information! Is it documentation somewhere? I want to investigate and fix #8035, but could not find documentation how layout switching works in R4.1. I mean your reply explains a lot, but maybe it is explained somewhere else too?

And why XKLAVIER_ALLOW_SECONDARY exactly? I tried to search for it and it seems that Qubes OS is almost the only somewhat popular project that relies on XKLAVIER_ALLOW_SECONDARY (I can easily be wrong about this).

gangamstyle commented 1 year ago

Debugging: 1) qubesdb-watch /keyboard-layout in guests returns nothing, and this prevents layout update in guests 2) qvm-prefs dom0 keyboard_loyout in dom0 returns nothing

Script that tracks layout changes in dom0 and updates keyboard_layout for qvm-prefs: /usr/lib/python3.8/site-packages/qubesadmin/tools/qvm_start_daemon.py It listens to X events using xcffib library https://github.com/tych0/xcffib and that library may be bugged.

gangamstyle commented 1 year ago

@marmarek can you please check if this pull request https://github.com/QubesOS/qubes-core-admin-client/commit/b99e45f081ab7c5ef51ed6be665dca3dae84ed02 can be affected by suspend/resume (this starts the bug)

sysfu commented 7 months ago

I'm troubleshooting an issue whereby dom0 keyboard layout and setxkbmap options are being ignored by a Windows 7 Qube. All linux Qubes do not have this issue and respect both dom0 keyboard layout and setxbkmap -options ctrl:nocaps setting.

Forum thread with the troubleshooting steps I've taken so far, maybe it's due to this same bug?

jamke commented 7 months ago

I'm troubleshooting an issue whereby dom0 keyboard layout and setxkbmap options are being ignored by a Windows 7 Qube.

I have Windows 10 for a while that does not care about keyboard layout of other qubes, including dom0. Is the propagation expected to work with Windows qubes at all?

sysfu commented 7 months ago

I'm troubleshooting an issue whereby dom0 keyboard layout and setxkbmap options are being ignored by a Windows 7 Qube.

I have Windows 10 for a while that does not care about keyboard layout of other qubes, including dom0. Is the propagation expected to work with Windows qubes at all?

I did some more research and believe this is due to missing Qubes Windows Tools. They were replaced with a dummy file around August 2023 on account of a Xen driver CVE.

You can manually downgrade to qubes-windows-tools-4.1.69 (for Qubes OS v4.2) but the updater will replace it with the dummy file again if you're not careful.

jamke commented 7 months ago

Without QWT it will not propagate for sure. I have QWT and it still never propagated on Win10 for me, so, I am not sure it should.

marmarek commented 7 months ago

I don't think keyboard layout switching is implemented in QWT yet.

-- Best Regards, Marek Marczykowski-Górecki Invisible Things Lab