Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work with Wayland #64

Open
moceap opened this issue Jan 16, 2022 · 12 comments
Open

Doesn't work with Wayland #64

moceap opened this issue Jan 16, 2022 · 12 comments

Comments

@moceap
Copy link

moceap commented Jan 16, 2022

Can't detect current keyboard layout in Wayland session.

@sergei-mironov
Copy link
Owner

Unfortunately, it is a strictly X11 app right now. Try to find another tool for Wayland.

@sergei-mironov
Copy link
Owner

sergei-mironov commented May 1, 2022

Originally I had no Wayland devices to think about it's support, but now I have a Pinephone which uses Wayland, so at least I can compile and run examples.

I think that it is not a good idea to integrate Wayland support to the originally-X11-only XkbSwitch.cpp files, but we may think about writing a separate tool with the same command-line interface.

Do you have any good examples of working with keyboard using this protocol?

@timsofteng
Copy link

@grwlf I use sway and layout can be changed with swaymsg externally.
It should not be hard to implement it.

@sergei-mironov
Copy link
Owner

sergei-mironov commented Jun 27, 2022

Afaik, X applications should run under Wayland's X compatibility layer called XWayland https://wayland.freedesktop.org/docs/html/ch05.html
Has anybody tried it with xkb-switch?

@1nikolas
Copy link

1nikolas commented May 7, 2023

Afaik, X applications should run under Wayland's X compatibility layer called XWayland https://wayland.freedesktop.org/docs/html/ch05.html Has anybody tried it with xkb-switch?

Yes it does run under xwayland but it seems xwayland doesn't sync the keyboard layouts with wayland.. It's like its own separate thing, I can set my layouts with setxkbmap and switch them/query them with xkb-switch but they don't affect the real keyboard layout in wayland. I have no idea where to open an issue about that..

@FrolovRuslan1
Copy link

FrolovRuslan1 commented Dec 7, 2023

Afaik, X applications should run under Wayland's X compatibility layer called XWayland https://wayland.freedesktop.org/docs/html/ch05.html Has anybody tried it with xkb-switch?

Hello again. I can help develop xkb-switch under Wayland. Wayland support libxkbcommon and Wayland API libwayland. Here is my test code where I can get list of layouts. BUT how I found out here libxkbcommon doesnt have tools to switch layouts.

I have ru and us layouts.
Here tests on Debian:
In Plasma Wayland:
1.

-> % xkb-switch --list
us
-> % ./wxkb_switch    
It prints keyboard layout only via xkbcommon
num: 1
English (US)
It prints keyboard layout via xkbcommon and wayland
num: 2
English (US)
Russian

In Plasma X11:
1.

-> % xkb-switch --list
us
ru
-> % ./wxkb_switch
It prints keyboard layout only via xkbcommon
num: 1
English (US)
Failed to connect to Wayland display

@sergei-mironov
Copy link
Owner

@FrolovRuslan1 I would be happy to accept the PR. Have some questions:

  1. What do you think, can we write an abstraction which would run the existing code on X, and the wayland code you have prototyped if we are on wayland? I think we can depart from making this class a C-structure with function pointers pointing to either X11 or Wayland implementations depending on the build configuration flag? (I am ok with moving towards pure-C implementation)
  2. What changes do we need in the CMake?

@FrolovRuslan1
Copy link

FrolovRuslan1 commented Dec 10, 2023

@FrolovRuslan1 I would be happy to accept the PR. Have some questions:

1. What do you think, can we write an abstraction which would run the existing code on X, and the wayland code you have prototyped if we are on wayland?  I think we can depart from making [this class](https://github.com/grwlf/xkb-switch/blob/master/src/XKeyboard.hpp) a C-structure with function pointers pointing to either X11 or Wayland implementations depending on the build configuration flag? (I am ok with moving towards pure-C implementation)

2. What changes do we need in the CMake?

I checked XKeyboard.hpp and yes, we can write an abstraction for Wayland. I think we can create Class automatically depends on environment variables. Or we can split the project on two. One for the X11 and one for Wayland because if we will be make project based on dependence of build configuration flag or runtime variable then the project growing up to unreadable size, moreover, I do not think that a new X11 analogue will appear under Linux in the near future.

P.S. I tested setxkbmap it is working but it crash DE switching. If you can please open issue for user help on Wayland and ask like that "Is Wayland have standard methods for switching keyboard layouts because xkbcommon doesnt have and setxkbmap crash DE switching layout." because for some reason I cant singup and register on Gitlab even through VPN it just doesnt send on google email.
I think if Wayland doesnt have such methods then we can use libxkbcommon for getting information about keyboard and setting via setxkbmap or yours implementation.

UPDATE 15.12.2023:
Open issue in Wayland.

@lolmaus
Copy link

lolmaus commented Jun 19, 2024

Any progress on this one? 🙏

@FrolovRuslan1
Copy link

Any progress on this one? 🙏

I hope that I get time at this summer for work at xkb-switch and my openswitcher projects, I have lot of work and study

@FrolovRuslan1
Copy link

FrolovRuslan1 commented Oct 13, 2024

@sergei-mironov

Check https://github.com/FrolovRuslan1/xkb-switch commits

On Wayland Plasma

ruslan@debian [02:27:23 PM] [~/xkb-switch] [feature/wayland_support]
-> % ./xkb-switch -d --list         
zsh: no such file or directory: ./xkb-switch
ruslan@debian [02:27:35 PM] [~/xkb-switch] [feature/wayland_support]
-> % cd build 
ruslan@debian [02:27:39 PM] [~/xkb-switch/build] [feature/wayland_support]
-> % ./xkb-switch -d --list
[DEBUG] xkb-switch version 2.1.0
/home/ruslan/xkb-switch/src/XKeyboard.cpp:156: raw layout string "us"
/home/ruslan/xkb-switch/src/XKeyboard.cpp:160: No raw variant string
num_layouts: 1
num_layouts_x11: 2
i: 0 layout: English (US)
i: 1 layout: Russian
[DEBUG] layout: us
[DEBUG] variant: <empty>
/home/ruslan/xkb-switch/src/XKeyboard.cpp:239: layout "us", variant ""
/home/ruslan/xkb-switch/src/XKeyboard.cpp:248: ... accepting with id #0
/home/ruslan/xkb-switch/src/XKeyboard.cpp:239: layout "", variant ""
us

@FrolovRuslan1
Copy link

FrolovRuslan1 commented Nov 21, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants