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

Can't get Capslock state on wayland #229

Open
Yatogaii opened this issue Jul 14, 2021 · 5 comments
Open

Can't get Capslock state on wayland #229

Yatogaii opened this issue Jul 14, 2021 · 5 comments

Comments

@Yatogaii
Copy link

This statement is only applicable to OS using xorg, and cannot get the value of capslock correctly in Wayland
key_state.capslock_in_effect = execute(COMMAND_STR_CAPSLOCK_STATE).size() >= 2;
I'm curious how to get the capslock value in Wayland

@kernc
Copy link
Owner

kernc commented Jul 14, 2021

Does setleds work, as pointed out in this SO thread?

@kernc
Copy link
Owner

kernc commented Jul 14, 2021

We already use setleds in case xset fails:

#define COMMAND_STR_CAPSLOCK_STATE ("{ { xset q 2>/dev/null | grep -q -E 'Caps Lock: +on'; } || { setleds 2>/dev/null | grep -q 'CapsLock on'; }; } && echo on")

Do you have it installed (part of kbd package).

@kernc
Copy link
Owner

kernc commented Jul 14, 2021

Reading /sys/class/leds/inputX::capslock/brightness is another option ...

@Yatogaii
Copy link
Author

#define COMMAND_STR_CAPSLOCK_STATE ("{ { xset q 2>/dev/null | grep -q -E 'Caps Lock: +on'; } || { setleds 2>/dev/null | grep -q 'CapsLock on'; }; } && echo on") It can get correct result on Xorg but the result is always 0 when it work on wayland.
I have tried setleds -D +caps command ,it can work at both Xorg and wayland , but it only works well on VT(i mean Ctrl+Alt+F2orF3 that window), it don't work on GUI.
I also tried using ioctl(fd,KBGETLED,&res);,but it always get 0.
Is it because of my virtual machine problem?
My OS is ubuntu16.04 using Xorg and ubuntu21.04 usging wayland.

@Yatogaii
Copy link
Author

I tried ioctl(fd,KDETLED,0x04) and it works well on GUI
However, regardless of the value of capslock, the return value of kdgetled is always 0. However, after kdset led, 0x04, no matter how you press the capslock key, the value of kdgetled will become 0x04 instead the true value of capslock state
It seems that the value of kdgetled is only 0 or the value modified by kdsetled, regardless of the state of the key itself
Any ideas?

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

2 participants