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

Fix hyprland/language events not working with keyboard names with commas in them #3224

Merged

Conversation

zjeffer
Copy link
Contributor

@zjeffer zjeffer commented May 6, 2024

Based on the proposal by @s1syph0s (#2137 (comment))

Should fix #2137 and #3222. Looking at https://wiki.hyprland.org/IPC/#events-list, activelayout has the parameters KEYBOARDNAME,LAYOUTNAME, so find_last_of should be more appropriate.

@dxrknesss @xadips Can you guys test this with your keyboard?

@dxrknesss
Copy link

YEAH IT'S FINALLY WORKING
image

logs:
image

huge thanks to you!

@zjeffer
Copy link
Contributor Author

zjeffer commented May 6, 2024

Mainly thanks to @s1syph0s ;)

Thanks for testing

@Alexays ready to merge

@Alexays Alexays merged commit 29917fb into Alexays:master May 7, 2024
8 checks passed
@Alexays
Copy link
Owner

Alexays commented May 7, 2024

Thans guys!

@zjeffer zjeffer deleted the fix/zjeffer/hyprland-language-commas branch May 7, 2024 17:30
zjeffer added a commit to zjeffer/Waybar that referenced this pull request May 7, 2024
zjeffer added a commit to zjeffer/Waybar that referenced this pull request May 7, 2024
@tirsek
Copy link

tirsek commented Jul 2, 2024

Looks like I have the opposite problem. My keyboard name does not have a comma in it, but one of my layouts do:

[2024-07-01 19:53:57.162] [debug] hyprland IPC received activelayout>>at-translated-set-2-keyboard,English (US, intl., with dead keys)
[2024-07-01 19:53:57.186] [debug] hyprland language didn't find matching layout
[2024-07-01 19:53:57.186] [debug] hyprland language onevent with  with dead keys)
[2024-07-01 19:53:57.186] [debug] hyprland language update with full name 
[2024-07-01 19:53:57.186] [debug] hyprland language update with short name 
[2024-07-01 19:53:57.186] [debug] hyprland language update with short description 
[2024-07-01 19:53:57.186] [debug] hyprland language update with variant 
[2024-07-01 19:53:57.186] [debug] hyprland language formatted layout name

If I revert the change back to using ev.find_first_of(',') it works for me, but of course this would break the other case with the comma in the keyboard name. Maybe the only way out of this (short of changing the Hyprland IPC format itself), will be to try every comma in the string, one by one, until a valid keyboard language is found?

tirsek added a commit to tirsek/waybar that referenced this pull request Jul 2, 2024
Commit 29917fb ("Fix hyprland/language events not working with keyboard
names with commas in them (Alexays#3224)") attempted to fix the problem, but
introduced the opposite problem.

The event data from Hyprland is "activelayout>>KEYBOARDNAME,LAYOUTNAME",
but both KEYBOARDNAME and LAYOUTNAME may contain embedded commas, so the
simple `find_first_of(',')` or `find_last_of(',')` solutions will break
things for different users.

This patch attempts to solve the problem by trying all combinations of
keyboardname and layoutname until one makes sense, either by matching
the keyboard name to the user-configured device name, or by matching the
layoutname to the list of valid layouts.
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.

hyprland/language active keymap does not update
4 participants