-
-
Notifications
You must be signed in to change notification settings - Fork 913
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: change layout event's separator #7275
base: main
Are you sure you want to change the base?
Conversation
The layout event separator is changed from "," to ";" to improve parsing ability, since some keyboard can also have "," in its name.
I think adding another event, e.g. Original |
Thanks for the input! I'll fix this soon |
Rereading a related issue, someone here #6298 (comment) said that some keyboards could contain Maybe let's just use Btw, see Lines 1007 to 1010 in 4fdc0d5
or Lines 2031 to 2033 in 4fdc0d5
|
you're avoiding the problem instead of fixing it. Just replace |
That would mean that IPC users would need to do that too, if they want to match a particular keyboard / layout, because now Having more unique separator character feels like a simpler change. |
|
As for escaping commas in keyboard / layouts - that would mean you still can't just split for it and get what you want (the same thing that ❯ echo "activelayout>>some\,weird\,keyboard,Some\,Layout" | awk -F '>>' '{print $2}' | awk -F ',' '{print $2}'
weird\ You'll need to (pre/post)process it like e.g. ❯ echo "activelayout>>some\,weird\,keyboard,Some\,Layout" | awk -F '>>' '{print $2}' | sed 's#\\,#~#g' | awk -F ',' '{print $1}' | sed 's#~#,#g'
some,weird,keyboard
~
❯ echo "activelayout>>some\,weird\,keyboard,Some\,Layout" | awk -F '>>' '{print $2}' | sed 's#\\,#~#g' | awk -F ',' '{print $2}' | sed 's#~#,#g'
Some,Layout As separator - it still has problem, at least for awk, ~
❯ echo "activelayout>>some,weird,keyboard\,Some,Layout" | awk -F '>>' '{print $2}' | awk -F '\,' '{print $1}'
awk: warning: escape sequence `\,' treated as plain `,'
some
~
❯ echo "activelayout>>some,weird,keyboard\,Some,Layout" | awk -F '>>' '{print $2}' | awk -F '\\,' '{print $1}'
awk: warning: regexp escape sequence `\,' is not a known regexp operator
some
but that's fixable in awk and isn't a problem in a saner ❯ echo "activelayout>>some,weird,keyboard\,Some,Layout" | awk -F '>>' '{print $2}' | awk -F '\\\\,' '{print $1}'
some,weird,keyboard
~
❯ echo "activelayout>>some,weird,keyboard\,Some,Layout" | awk -F '>>' '{print $2}' | awk -F '\\\\,' '{print $2}'
Some,Layout This could work, but is worse than just unique not escaped character. Admittedly, echo "activelayout>>some,weird,keyboard||Some,Layout" | awk -F '>>' '{print $2}' | awk -F '||' '{print $1}'
some,weird,keyboard||Some,Layout
~
❯ echo "activelayout>>some,weird,keyboard||Some,Layout" | awk -F '>>' '{print $2}' | awk -F '||' '{print $2}'
~
❯ echo "activelayout>>some,weird,keyboard||Some,Layout" | awk -F '>>' '{print $2}' | awk -F '\|\|' '{print $2}'
awk: warning: escape sequence `\|' treated as plain `|'
~
❯ echo "activelayout>>some,weird,keyboard||Some,Layout" | awk -F '>>' '{print $2}' | awk -F '\\|\\|' '{print $2}'
Some,Layout
~
❯ echo "activelayout>>some,weird,keyboard||Some,Layout" | awk -F '>>' '{print $2}' | awk -F '\\|\\|' '{print $1}'
some,weird,keyboard But that's, again, purely awk's problem. For waybar it wouldn't matter. But
You get what you split for, no need to learn any escaping. |
Should I just replace the separator from |
I'd propose something like
where integer This allows us to 1) correctly parse the event regardless of layout and keyboard name contents 2) maintain the backwards compatibility with |
This sounds interesting! However, using A more extreme solution is to output the event string as a JSON, which requires us to change all event outputs. |
dumb statement, what is there to make you so sure there is any character that will forever be unique? |
Practical experience of how humans make up names for things meant to be read by other humans?
Maybe someone who has a keyboard with a fully programmable controller in it can mess this up. But if you expect a completely arbitrary text in the name and layout, sure, escaping the separator character is the way. If we're being this pedantic, escaping the separator during the serialization and unescaping on user side should always be done, for all events with arbitrary output, and maybe all for the sake of consistency / simpler maintainability should the expected text change later. I just think that the less unescaping the user needs to do, the better. |
escaping is a common practice and I still believe |
I tried to use
If I remove the Using rust to parse the event output, trying to read |
you need to put |
Sure, you're the boss anyway. It will still break the API if you had keyboard with a comma defined and now event has I personally think adding v2 is better, regardless of the solution. @s1syph0s I'm pretty sure he means replace all EDIT: Or not...? Needing to split by If you join with literal |
Hi, is there any update to this issue? I'll be happy to adjust the PR |
well I am still convinced escaping the commas with |
I created a commit that escapes the comma. Could you review the code? |
it's the opposite of what we want. We want to escape the commas in the layout name |
Hi, sorry for the late response.. I was taking a break from software dev in my free time.. I tried escaping the comma in both the layout and the language, but the event still can't be parsed properly..
Another idea that I would propose is to remove the comma completely from the keyboard name and the layout, but this is also not backwards compatible. To fix this in waybar for example, we also need to remove the commas from the input keyboard name. What do you think about this? PS: I'm having a problem when using the flake's devShell. Currently, the flake only have meson and no cmake. I followed the instruction to build the project in debug mode using meson, and it also generates
Am I doing something incorrectly? |
Describe your PR, what does it fix/add?
The layout event separator is changed from "," to ";" to improve parsing ability, since some keyboard can also have "," in its name. Alexays/Waybar#2137 Alexays/Waybar#3224
Is there anything you want to mention? (unchecked code, possible bugs, found problems, breaking compatibility, etc.)
Breaks compability with waybar's hyprland/language module.
Is it ready for merging, or does it need work?
This is ready for merging