any1 / wayvnc

A VNC server for wlroots based Wayland compositors
ISC License
1.08k stars 68 forks source link

No keyboard layout switching is supported #205

Open dluciv opened 1 year ago

dluciv commented 1 year ago

First, thank you for this great project!

In many languages, national characters require different keyboard layouts. But only single layout works at time. When trying to specify multiple ones (via sway config, environment or wayvnc config), it says: Multiple keyboard layouts have been specified, but only one is supported.

There are some workarounds possible, but they are pretty ugly and mostly unusable.

dluciv commented 1 year ago

Workarounds

Then workarounds, just to make fun and possibly to borrow some ideas from hem.

With Sway (1)

  1. Launch sway with single layout and wayvnc.
  2. Change layout in sway config to somewhat like xkb_layout "us,ru" or us,el or us,ka or whatever you need.
  3. Use sway hotkey to reload settings, while still keeping wayvnc running.

Then, wayvnc notices nothing and layout can be switched, for example, from shell using swaymsg input "0:0:virtual_keyboard" xkb_switch_layout next (which can even be bound to a hotkey if needed). And it works from the first glance. Until you disconnect.

With Sway (2)

bindsym $mod+Alt+1 input "type:keyboard" xkb_layout us
bindsym $mod+Alt+2 input "type:keyboard" xkb_layout ru

Or similar setting. Also lets sway rule it all. Sway switches the layout, wayvnc continues working smoothly.

No layout switching at all

Not related to sway or any particular environment. The other funny workaround is to use no layout switching at all. One can launch two wayvnc instances with different configuration regarding keyboard layout. Connect to them both and Looks stupid, nearly unusable in practice, but works smoothly =).

any1 commented 1 year ago

Keyboard maps are used to look up a key on the keyboard that generates a particular symbol. If the chosen map contains the given symbol, things will mostly work, but it is not guaranteed that the "right" key will be pressed. For typing, this isn't really a problem, but it might be for other applications such as gaming.

There are clients such as TigerVNC and wlvncc that can send key codes directly instead of converting them to symbols. The best solution is to use such a client because that makes keyboard layouts completely irrelevant.

Anyway, if you want to implement layout switching, I suggest that you look into adding a command for it to wayvncctl.