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

RMLVO: support for applying option on specific layout index #500

Open
wismill opened this issue Aug 22, 2024 · 8 comments
Open

RMLVO: support for applying option on specific layout index #500

wismill opened this issue Aug 22, 2024 · 8 comments
Labels
compile-keymap Indicates a need for improvements or additions to keymap compilation enhancement Indicates new feature requests

Comments

@wismill
Copy link
Member

wismill commented Aug 22, 2024

See the corresponding xkeyboard-config issue.

The idea would be to be able to have a suffix per option, such as it applies only to some layout indexes.

Some preliminary ideas:

  • , cannot be used as a suffix delimeter, as it is the option separator.
  • : should not be used as a suffix delimeter, e.g. eurosign:e:2, because it is ambiguous.
  • @ seems an interesting candidate; it clashes with nothing currently. E.g.: eurosign:e@2
  • We should embrace Modern rules #362 and introduce @all, @first, etc. as well.
  • We need DE devs to be implied, if we want a proper UI to be developed.
  • There should be none or only very limited breakage, as it is the “compiled” keymap that is shared by the compositor with the apps, not the RMLVO values.
@wismill wismill added enhancement Indicates new feature requests compile-keymap Indicates a need for improvements or additions to keymap compilation meta: xkeyboard-config Issue related to xkeyboard-config and removed meta: xkeyboard-config Issue related to xkeyboard-config labels Aug 22, 2024
@whot
Copy link
Contributor

whot commented Aug 26, 2024

Or make this a proper builder API so we don't have to worry about magic syntax. Something like:

rmlvo = xkb_rmlvo_new();

layout = xkb_rmlvo_layout_new("us");
xkb_rmlvo_layout_set_variant(layout, "dvorak");
xkb_rmlvo_layout_add_option("banana");
xkb_rmlvo_layout_add_option("orange");
xkb_rmlvo_add_layout(layout);

// repeat for layout 2 if need be

keymap = xkb_keymamp_new_from_rmlvo(context, rmlvo, flags);

or, for those who really like varargs:

layout = xkb_rmlvo_layout_new("us",
        XBK_RMLVO_VARIANT, "dvorak",
        XKB_RMLVO_OPTION, "banana",
        XKB_RMLVO_OPTION, "banana",
        XKB_RMLVO_END);

sd-bus uses the latter extensively but in your case I think the first approach is better.

No backwards compat issue either since it's a new API :)

@wismill
Copy link
Member Author

wismill commented Aug 26, 2024

I like this idea (without varargs)! But the new suffix syntax would still be useful for CLI, wouldn't it?

We need to figure out how to handle this in xkeyboard-config. The standard way is to duplicate for each layout index. #362 may come handy. Or we may implement an expection in rules resolving for the new API.

@whot
Copy link
Contributor

whot commented Aug 26, 2024

I like this idea (without varargs)! But the new suffix syntax would still be useful for CLI, wouldn't it?

Might be better to dream up a new syntax. after all the xkbcommon cli isn't quite as wide-spread through config files everywhere as e.g. setxkbmap's.

A rather lame but easyn enough approach would be:

xkbcli compile-keymap --layout-1 us --variant-1 dvorak --option-1=banana --option-1=orange

Since we only have 4 groups that's not impossible to implement.

@wismill
Copy link
Member Author

wismill commented Aug 26, 2024

We really need to add short CLI arguments 😅.

And we need to keep #37 in mind.

@whot
Copy link
Contributor

whot commented Aug 26, 2024

We really need to add short CLI arguments 😅.

heh, sort-of but I usually get angry when I see scripts using short args, forcing me to decypher what -xDRtdg means in that context... that's why I'm quite a fan of adding long args only, these days Ctrl+R should get you 80% of the way there anyway :)

And even if we want more than 4 groups/layouts, well, we're not going to run out of numbers, so --layout-256 for the truly bonkers can be added on demand ;)

@wismill
Copy link
Member Author

wismill commented Aug 26, 2024

And even if we want more than 4 groups/layouts, well, we're not going to run out of numbers, so --layout-256 for the truly bonkers can be added on demand ;)

Then we would need to change the args-parsing function or use a macro, because this will not scale.

Maybe add only a --index arg that overload the next arg, e.g.:

[…] --layout us,de --index 3 --layout es --option … --index 2 --option …

@whot
Copy link
Contributor

whot commented Aug 26, 2024

what I don't like about --index arguments is that instead of each argument meaning exactly one thing, it's now a state machine that you need to remember and/or script correctly.

I'd have to look it up but there's a way you can expand a macro into more things so we can have a #define opt("--layout", 256) which then expands into the right getopt lines. Though unless we really want to support a ridiculous number of layouts it's easier to just type this out once and be done with it forever.

@wismill
Copy link
Member Author

wismill commented Aug 28, 2024

I think that supporting this feature properly would require to add support in rules files for option component with a layout index, e.g. option[2] = symbols.

However, since layout matches a single layout and layout[1] matches the first layout in a 2+ layouts config, we would not be able to maintain backward compatibility or consistency. So I would skip the digits indexes and implement #362 indexes directly:

  • single, e.g. option[single]
  • first
  • later
  • any
  • a new value, auto, that implements the current behavior, e.g. option would be the same as option[auto].

But wait, it does not make sense for some options to be applied on specific layout indexes (e.g. types, compat, option that modify modifiers mappings). So we would also need to communicate this via the XML registry file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compile-keymap Indicates a need for improvements or additions to keymap compilation enhancement Indicates new feature requests
Projects
None yet
Development

No branches or pull requests

2 participants