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

feat: Add options to set initial state for caps lock and num lock #4831

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Sydiepus
Copy link

This adds the ability set an initial state for
caps lock and num lock using kb_capslock and
kb_numlock InputConfig options.

Closes:
#4225

@Sydiepus
Copy link
Author

Tested the CI on my fork
It should be working since nothing was changed from the last PR, I couldn't test because Qtile is not starting.

libqtile/backend/wayland/inputs.py Outdated Show resolved Hide resolved
"""Set the initial num/caps lock state of the keyboard."""
mask = ModifiersMask(self.keyboard)
if numlock:
mask.add("Mod2")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it true that Mod2 is always numlock? At least on x11, you'd need to query the modmap to see which thing is numlock, and add that one.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure, maybe if the keys where remapped it will be different.
I don't really understand how xkb work but there's a modifier named NumLock does it guarantee that it's always numlock?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it'll work if you put NumLock in there, but I honestly don't know. I think you probably have to do a xkb GetMap request to really get this to work right, which will require some changes in xcffib.

@jwijenbergh
Copy link
Contributor

jwijenbergh commented May 23, 2024

To be complete we should also call wlr_keyboard_led_update. But it's not exposed in pywlroots (yet)

@Sydiepus
Copy link
Author

To be complete we should also call wlr_keyboard_led_update.

the pywlroots implementation of notify_modifiers calls wlr_keyboard_notify_modifiers which in turn calls keyboard_led_update see here

@jwijenbergh
Copy link
Contributor

To be complete we should also call wlr_keyboard_led_update.

the pywlroots implementation of notify_modifiers calls wlr_keyboard_notify_modifiers which in turn calls keyboard_led_update see here

Oh I assumed it was needed because sway did it

@@ -25,6 +25,7 @@
# SOFTWARE.

from libqtile import bar, layout, qtile, widget
from libqtile.backend.wayland.inputs import InputConfig
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would fail if the Wayland dependencies are not present.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could include these lines in the default config but comment them out. You can also add some comments to explain what they're for.

@jwijenbergh may have a different idea.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also do the import in an if backend is Wayland block. But at this point it's better to just make NumLock the default and have a false version commented?

@Sydiepus
Copy link
Author

Sydiepus commented Aug 4, 2024

I was finally able to resolve the issues I was having and I was able to test the changes.
I tried using a rule on an external keyboard and it worked.

@Sydiepus Sydiepus marked this pull request as ready for review August 4, 2024 17:11
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

Successfully merging this pull request may close these issues.

4 participants