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

Feature request: Delegate transparent keys to first or specified layer instead of defsrc #435

Closed
rosshadden opened this issue Jun 7, 2023 · 3 comments · Fixed by #440
Closed
Labels
enhancement New feature or request

Comments

@rosshadden
Copy link

rosshadden commented Jun 7, 2023

Is your feature request related to a problem? Please describe.

Like I am sure many others (including you I think?) my defsrc is some qwerty-ish layout because that maps to my actual physical keyboards, and my "main" layer is dvorak.

I found by experimentation and reading docs that any base layers with transparent keys will use keys from the defsrc, as kanata does not have the layer stack concept that kmonad does. I almost never miss the stack concept and can appreciate that not having it reduces complexity quite a bit, but in this case I really do miss it. Basically any layer that doesn't have all keys mapped is just qwerty for all the transparent keys.

Describe the solution you'd like

I think a solution that could avoid any kind of layer stack would be to promote a layer to be the "base" or "main". It could be a setting, or it could just be the first layer. Just making it the first layer would make sense to me because the first layer already gets automatically used as the active layer when you run kanata. So in this case, maybe if there's a setting it would be a boolean "delegate-to-first-layer" or something, rather than a string layer name.

@rosshadden rosshadden added the enhancement New feature or request label Jun 7, 2023
@rszyma
Copy link
Contributor

rszyma commented Jun 8, 2023

layer-while-held delegates transparent keys to previous layer, but only for as long as the layer key is held. However, there is a trick with fakekeys to make it persistent that allows effectively emulating "layer-switch with transparent keys delegating to previous layer".

See #393 (comment) - an example that uses the above trick. You could use it to help you solve your problem for now.

Also #360 proposing a related feature.

@jtroo
Copy link
Owner

jtroo commented Jun 8, 2023

This proposal seems like it's more backwards-compatible and workable than changing the action-layer selection method.

Some implementation details, in case someone wants to try their hand at this before I can get to it. The loop where the transparent actions get assigned is here:

for (i, (layer_action, defsrc_action)) in layers_cfg[layer_level * 2][0]

One could potentially swap the defsrc layer to be the first parsed layer somewhere in the vicinity of this code.

Also - a random aside - I read through the other bits of the function and it looks like this comment is no longer relevant:

        // If key is unmapped in defsrc as well, default it to the OsCode for that index if the
        // configuration says to do so.

The function header comment is also inaccurate now hah. That's not what it does at all.

/// Mutates `layers::LAYERS` using the inputs.

Edit: fixed in main

@rosshadden
Copy link
Author

Your changes work great on Linux. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants